• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

page redirect not working

PHP page redirect not working.

I have this code in login.php page:

echo "<td width=100%><br><br><br><br><center><b> Thank you ! You are now logged in . <br>
<br><a href=index.php>Click here to continue</a></b></center></td>";

instead of asking the user to click the link, i want to redirect the page directly to index.php, so i commented the echo and gave:

header("Location: index.php");

but , the location shows only 'login.php' it doesnot show index.php, what could be the reason?

any help is appreciated.
thanks.
0
CWS (haripriya)
Asked:
CWS (haripriya)
  • 2
1 Solution
 
nizsmoDeveloperCommented:
you cannot redirect using the header function after something has been output into the webpage.
Alternatively though, you can redirect using something like this:

$redirector = "<meta HTTP-EQUIV=\"refresh\" content=0;url=\"index.php\">";
      
echo "<td width=100%><br><br><br><br><center><b> Thank you ! You are now logged in . <br>
<br><a href=index.php>Click here to continue</a></b></center></td>";
echo $redirector;

You can change the content=0 value to be 2 or 3 or whatever you want, this is how many seconds to wait until redirection occurs.

Let me know how you go.
0
 
CWS (haripriya)Author Commented:
great. thanks!
0
 
nizsmoDeveloperCommented:
Glad to be of assistance :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now