Page wont redirect

in php

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 1706 Views - Last Post: 25 March 2010 - 07:24 AM Rate Topic: -----

#1 Guest_Jason Rowe*


Reputation:

Page wont redirect

Posted 24 March 2010 - 08:30 PM

I have setup wamp server on my PC to be able to learn some php/mysql and have run into a problem.. I made a login section to the site but wanted to be able to add a page redirect if the user is invalid..i know this seems easy as a header adjustment. here is what i have

I have a test file named redirect.php with only the following code in it.

 
<?php
header ("Location: http://www.google.com"); 
?>


but when the redirect.php page loads which contains the header redirection nothing is shown on the browser. eventually id like to add the header redirection to an if statement incase a incorrect user is submitted but I cant even get this simple redirect to work.. I do know already that all header redirections have to be put on before even a blankspace is shown on the screen. please help, thanks!

Is This A Good Question/Topic? 0

Replies To: Page wont redirect

#2 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: Page wont redirect

Posted 24 March 2010 - 08:32 PM

The only syntax thing I would think is the space between header and the '('. Everything else looks fine.

--

Greg
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5354
  • View blog
  • Posts: 27,312
  • Joined: 10-May 07

Re: Page wont redirect

Posted 24 March 2010 - 08:33 PM

Providing only the header command, we can't really evaluate your code.

Since it's at least initiating a page load, can you verify that you can load Google, by using that exact URL? Maybe the problem isn't in the code.
Was This Post Helpful? 0
  • +
  • -

#4 Guest_Jason Rowe*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 08:36 PM

well with the code provided, altho not the complete code that I will eventually use, it should work and send my browser to google.com still correct? At the moment its not.
Was This Post Helpful? 0

#5 Guest_Guest*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 08:40 PM

Yes ive copied and pasted the url and I connect to google fine. i know my php and mysql are active as i can query the database and my .php files load fine but for some reason my page redirecting code dont work even for the simple redirect.php file listed above
Was This Post Helpful? 0

#6 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: Page wont redirect

Posted 24 March 2010 - 08:41 PM

pencils merely stating that it could be something else in the code or something all together, and it is - as I uploaded your exact code here and it works.

--

Greg
Was This Post Helpful? 0
  • +
  • -

#7 Guest_Guest*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 08:44 PM

hmm..could it be settings for wamp or internet explorer? not a clue why no header redirects are working then.. weird
Was This Post Helpful? 0

#8 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5354
  • View blog
  • Posts: 27,312
  • Joined: 10-May 07

Re: Page wont redirect

Posted 24 March 2010 - 08:47 PM

Maybe Google doesn't want your rejected traffic :)

Try Yahoo!, as they'll take whatever they can get.
Was This Post Helpful? 0
  • +
  • -

#9 Guest_Guest*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 08:52 PM

:cry2: yahoo not working either.. so weird.. any one else might know why the page isnt redirecting?
Was This Post Helpful? 0

#10 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5354
  • View blog
  • Posts: 27,312
  • Joined: 10-May 07

Re: Page wont redirect

Posted 24 March 2010 - 09:00 PM

If following gregwhitworth's posted link doesn't work, then I would recommend using a different browser.
Was This Post Helpful? 0
  • +
  • -

#11 Guest_Guest*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 09:06 PM

Ive found a work around using:

	<?php
		    echo '<HTML><head>';
			echo '<META HTTP-EQUIV="Refresh" Content="0; URL=http://www.google.com">';
			echo '</head><body></body></HTML>';
	?>




just would really like to know why the header redirect will only load a blank page..

Im using IE8 currently..
Was This Post Helpful? 0

#12 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5354
  • View blog
  • Posts: 27,312
  • Joined: 10-May 07

Re: Page wont redirect

Posted 24 March 2010 - 09:06 PM

Eww, Meta Refresh.

Have you tried another browser?
Was This Post Helpful? 0
  • +
  • -

#13 Guest_Guest*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 09:11 PM

yep just tried with firefox and it just loads a blank page as well.
Was This Post Helpful? 0

#14 JennaPeterson88  Icon User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • Posts: 39
  • Joined: 17-March 10

Re: Page wont redirect

Posted 24 March 2010 - 10:01 PM

Have you tried using a javascript refresh? I know some don't like javascript options, but I've never had a problem with it.

This post has been edited by JennaPeterson88: 24 March 2010 - 10:13 PM

Was This Post Helpful? 0
  • +
  • -

#15 Guest_Jason Rowe*


Reputation:

Re: Page wont redirect

Posted 24 March 2010 - 10:16 PM

thanks for the reply. I have been able to get the javascript redirect version to work but wanted to use header('location:...') incase javascript was turned off. ive been searching for bugs or certain configs for wamp/php to see if maybe there was other reports of this problem..really weird as Im following the header guidelines as described on the php site and still wont work right..sucks..
Was This Post Helpful? 0

  • (2 Pages)
  • +
  • 1
  • 2