Dear All,
I have a simple login script, when the user put the correct information the loop is working but when they put wrong informtion the loop is not working. Kindly find the below code.
The statement after if($result<0) is not working.
I have a simple login script, when the user put the correct information the loop is working but when they put wrong informtion the loop is not working. Kindly find the below code.
The statement after if($result<0) is not working.
Code:
<?php
include("dbConfig.php");
if(isset($_POST['login'])){
$userid = $_POST['userid'];
$userpassword = $_POST['password'];
$usertype = $_POST['usertype'];
//$sql = mysql_query("SELECT * FROM logintable where UserID = '$userid'");
//if($sql){
$sql2 = mysql_query("SELECT * FROM logintable where UserID = '$userid' and UserPassword='$userpassword'");
//echo "h2i";
$result = mysql_num_rows($sql2) or die(mysql_error());
if($result<0){
echo "Sorry";
exit;
}
else{
while($row = mysql_fetch_array($sql2)){
$usertype1 = $row['UserType'];
$username = $row['UserName'];
$userlastlogin = $row['UserLastLoginDateTime'];
$userlastip = $row['UserLastIP'];
echo $usertype1."-".$username."-".$userlastlogin."-".$userlastip;
SESSION_START();
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
echo $_SESSION['userid'];
}
}
/*}
else{
echo "Sorry";
}*/
}
?>
Comment