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!
I want to direct user to courses.html if user name and password is correct and if incorrect wrong.html.
I tried this but every time even user name and password is correct or incorrect is goes to wrong.html.
Any body help me to fix this problem.
Thanks
Last edited by Benjamin on Sat Nov 19, 2011 5:10 am, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
<?php
if (isset($_POST['id'])) {
$id=$_POST['id'];
$pw=$_POST['pw'];
if($id=='myid' && $pw =='mypw') {
header('Location: http://127.0.0.1/courses.html'); //Give the full web document root here.
}
}
elseif (isset($_POST['id'] && $id!='myid' && $pw!='mypw')) {
echo "You have entered an incorrect username and/or password. Please try again.";
sleep(3);
header('Location: http://127.0.0.1/wrong.html'); //Give the full web document root here.
}
else {
echo "You have not entered any valid information."
sleep(3);
header('Location: http://127.0.0.1/wrong.html'); //Give the full web document root here.
}
?>