i am trying to create a page "welcome.php" which takes in information and i get all things working except the redirect when user submits the page.
i used header("location : about.php") for redirect but it doesnt redirect to that page.instead it displays a blank page with the address in address bar remaining same as previous page i.e "welcome.php".if i add an echo "hii"; line below the header() then it prints hii on the page and this time also with the address in address bar remaining same as previous page.
please help.any help would be very much appreciated.
Thanks in advance.
help regarding redirect using header(location : "")
Moderator: General Moderators
-
aliasnikhil
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 20, 2011 10:50 am
-
aliasnikhil
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 20, 2011 10:50 am
Re: help regarding redirect using header(location : "")
i found out a solution
i typed header(location : "about.php");
i removed the space and retyped it as header(location:"about.php");
it worked but now the problem is it works with firefox but chrome gives the same problem as before.
i typed header(location : "about.php");
i removed the space and retyped it as header(location:"about.php");
it worked but now the problem is it works with firefox but chrome gives the same problem as before.
Re: help regarding redirect using header(location : "")
Code: Select all
header('Location: about.php');
exit;Call exit() or die() after declaring a location header to prevent execution of any code appearing after that point, which could have unintended consequences.
Read PHP Manual: header() for additional important notes.
-
aliasnikhil
- Forum Newbie
- Posts: 3
- Joined: Sun Mar 20, 2011 10:50 am
Re: help regarding redirect using header(location : "")
thanks a lot,it worked 
Re: help regarding redirect using header(location : "")
This is about PHP code, not General Discussion. Moving thread.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: help regarding redirect using header(location : "")
Older browsers may not understand relative paths, however. It is best to use absolute paths, just in case.McInfo wrote:For complete compliance with the standard (as described in section 14.30 of RFC 2616), the first letter of "Location" should be capitalized and an absolute URI should be used. A relative URI usually works, however.Code: Select all
header('Location: about.php'); exit;
Call exit() or die() after declaring a location header to prevent execution of any code appearing after that point, which could have unintended consequences.
Read PHP Manual: header() for additional important notes.