Re: PHP Redirection If Login Fails.

From: Date: Fri, 09 Jul 2004 10:37:10 +0000
Subject: Re: PHP Redirection If Login Fails.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190051@lists.php.net to get a copy of this message
Here's the code in question: I'd ideally want the user to only be directed to this page if login is successful. Directed to another page if unsuccessful but even the error messages do not display which I find strange... /* Verify Login */ $sql = "SELECT UserFirstName,UserID,UserPassword,FurtherComments FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'"; $result = mysql_query($sql) or die ("could not select database"); $num = mysql_num_rows($result); if ($num == 1) //Login Name Was Found { $sql = "SELECT UserID FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]' AND UserPassword=('$_POST[TXT_UserPassword]')"; $result2 = mysql_query($sql) or die("Couldn't execute query #2. MySQL Error: " . mysql_error()); $num2 = mysql_num_rows($result2); if ($num2 > 0) // password is correct { $_SESSION['auth']="yes"; $logname=$_POST['TXT_UserID']; $_SESSION['logname'] = $logname; $today = date("Y-m-d h:m:s"); $sql = "INSERT INTO Logon (loginName,loginTime) VALUES ('$logname','$today')"; mysql_query($sql) or die("Couldn't execute query. MySQL Error: " . mysql_error()); } else // password is not correct { unset($do); $message="The Login Name, '$_POST[TXT_UserID]' exists, but you have not entered the correct password! Please try again.<br>"; } } elseif ($num == 0) // login name not found { unset($do); $message = "The Login Name you entered does not exist! Please try again.<br>"; } -- ----------------------------- Michael Mason Arras People www.arraspeople.co.uk ----------------------------- "Harlequin" <michael.mason@arraspeople.co.uk> wrote in message news:20040709095425.15354.qmail@pb1.pair.com... > Hi all I've created a page that allows registered users who have previously > registered and been entered into the database to login. However, for some > reason if a user login fails my code does not display the appropriate error > message. > > Ideally I would like the users to be redirected to another page rather than > the login page if they fail but I need some help with the code. > > Anyone...? > > -- > ----------------------------- > Michael Mason > Arras People > www.arraspeople.co.uk > -----------------------------

« previous php.general (#190051) next »