PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kirtan007
Forum Newbie
Posts: 2 Joined: Sat Jun 06, 2009 1:30 am
Post
by kirtan007 » Sat Jun 06, 2009 1:34 am
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>';
}
Last edited by
Benjamin on Sat Jun 06, 2009 1:37 pm, edited 1 time in total.
Reason: Changed code type from text to php.
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Sat Jun 06, 2009 8:24 am
Use something to persist the state. Sessions will probably be a good route.
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Sat Jun 06, 2009 10:26 am
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.
kirtan007
Forum Newbie
Posts: 2 Joined: Sat Jun 06, 2009 1:30 am
Post
by kirtan007 » Sun Jun 07, 2009 2:56 am
Thank you Vry much for helping