im trying to create an auto logout system that will automatically log out of the system when the page is inactive,i am a newbie and when i added code to my login page im getting these warnings
Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\how are things\admin panel\login.php on line 80
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\how are things\admin panel\login.php on line 81
the code on line 80 and 81 are these below respectively
if($no_rows > 0){
while($resGetAdmin = mysql_fetch_assoc($rs_user))
this my code i added
$rs_user= mysql_query($check_login);
$no_rows = mysql_num_rows($rs_user);
if($no_rows > 0){
while($resGetAdmin = mysql_fetch_assoc($rs_user)){
$selQuery="select * from login where user_id=".$resGetAdmin['user_id'] ." AND loginDate ='$current_date'";
$rgetData= mysql_query($selQuery);
$num_login = getSqlNumber($selQuery);
if($num_login==0) {
$insQuery= "insert into login (user_id,loginTime,loginDate,count) values (".$resGetAdmin['user_id'].",'$current_time','$current_date',1)";
$login_user= mysql_query($insQuery);
$insert_id=mysql_insert_id();
$_SESSION['loginTime']=$current_time;
}else{
$count = mysql_result($rgetData,0,’count’);
$count = $count+1;
$updateQuery= "update login set loginTime='$current_time' ,loginDate='$current_date' , count ='$count' where user_id=".$resGetAdmin['user_id'] ." AND loginDate='$current_date'";
$login_user= mysql_query($updateQuery) or mysql_error();
$_SESSION['loginTime']=$current_time;
}
$_SESSION['user_id']=$resGetAdmin['user_id'];
header("Location: index.php");
exit;
}
}
this was my original login page before i added the code above
<?php
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password =($_POST['password']);
$hash_password = md5($password);
$hash_password1 = sha1($hash_password);
$hash_password2 = crypt($hash_password1,"st");
$hash_password3 = hash("sha512",$hash_password2);
$guess = $_POST['captcha'];
$real = (isset($_SESSION['real'])) ? $_SESSION['real'] : "";
if (empty($guess))
{
die("Please enter the correct CAPTCHA.<br>");
}
if (!empty($guess) && $guess !== $real)
{
die("Please enter the correct CAPTCHA.<br>");
}
if(empty($username) or empty($password)){
echo "<p>fields empty !</p>";
}
else {
$check_login = mysql_query("SELECT id, type FROM users WHERE username='$username' AND password='$hash_password3'");
if(mysql_num_rows($check_login) == 1) {
$run = mysql_fetch_array($check_login);
$user_id = $run['id'];
$type = $run['type'];
if($type == 'd'){
echo "<p> Your Account is deactivated byt the site admin!</p>";
} else {
$_SESSION['user_id'] = $user_id;
header('location: index.php');
}
} else {
echo "<p> User Name or Password incorrect!</p>";
} }
}
?>
i pasted the whole code on the login page but i left the timeout.php page,thanks in advance guys