I'm a beginner at php so please excuse me if this is a simple question.
I recently impressed myself by managing to get a login script working from a tutorial I foun on the web. I tried to add html to it to make it look cooler. It all seems to be working well except for one aspect. When the user enters in wrong details for example the wrong password the scripts goes:
if ($_POST['passwd'] != $info['password']) {
die('Your Password Is Incorrect');
}
so the die command kills the script and prints Your Password Is Incorrect. However by killing the scipt it doesn't run the rest of the html on the page so it ends up looking strange. Is there away writing something along the lines of
if password is incorrect
go to location 'wrongpassword.php'
or a better way of not letting the user login and informing them that they've entered invalid info?
if ($_POST['passwd'] != $info['password']) {
echo 'Your Password Is Incorrect';
?>
//---------------
// Html here
//---------------
<?php
die();
}
?>
//---------------------------------------------------
// You'd need the same html here though aswell...
//---------------------------------------------------
Or you can just use the exit() command where you currently have the die command.
exit() will stop the php script, but not whatever comes after the php script.
eg.
PHP Code:
if ($_POST['passwd'] != $info['password']) {
echo 'Your Password Is Incorrect'; exit(); }
?>
Or you can just use the exit() command where you currently have the die command.
exit() will stop the php script, but not whatever comes after the php script.
eg.
PHP Code:
if ($_POST['passwd'] != $info['password']) {
echo 'Your Password Is Incorrect'; exit(); }
?>
die; and exit; are actually both the same command - http://uk2.php.net/die
instead, try using return;
__________________
My Website: Sargant.Com Noisebox, a simple but powerful shoutbox script