Page 1 of 1

How to Write on page after Redirecting

Posted: Sat Jun 06, 2009 1:34 am
by kirtan007
i wan to redirect user to index.php page if login was not successfull and after redirecting i want to write on that page "Invalid Password"

How do i accompnish that task

??

i have coded this

Code: Select all

if ( $rownum > 0)
{
 
 
header('Location:google.com');
}
else 
{
header('Location:index.php');
echo '<font color=red>Invalid Password</font>';
}
 

Re: How to Write on page after Redirecting

Posted: Sat Jun 06, 2009 8:24 am
by jayshields
Use something to persist the state. Sessions will probably be a good route.

Re: How to Write on page after Redirecting

Posted: Sat Jun 06, 2009 10:26 am
by mikemike
Or use GET to pass a value onto your forwarded page:

Code: Select all

# if ( $rownum > 0)
 {
    header('Location:google.com');
 } else {
    header('Location:index.php?msg=Invalid+password');
 }
In index.php:

Code: Select all

<?php
echo '<span style="color:red;">'.$_GET['msg'].'</span>';
?>
Can I point out though that you're use of redirects is wrong. The 'Location' header requires an absolute URL. Where most browsers do accept this, it's still wrong.

Re: How to Write on page after Redirecting

Posted: Sun Jun 07, 2009 2:56 am
by kirtan007
Thank you Vry much for helping :)