Saat saya mencoba login keluar error seperti ini:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index\backup\user\auth.php on line 16
Mungkin Akun Anda Dalam Status Disable Silahkan Login!
Berhubunga saya sudah Pusing dan mencoba sendiri namun belum juga berhasil, jadi saya ingin tahu dimana letak kesalahan saya. Berikut ini Source yang saya buat:
File
Login.php<table width="200" border="1">
<form method="post" action="auth.php">
<tr>
<td>Username</td>
<td><input name="username" type="text"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="text"></td>
</tr>
<tr><td colspan="2"><input type='submit' value="Login"></td></tr></form>
</table>
File
Auth.php<?php
//Koneksi ke Database
include "../config/config.php";
//Mengambil data dari Form
$username = $_POST['username'];
$password = md5($_POST['password']);
//Mencegah SQL Injection
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query ="SELECT FROM user WHERE username='$username' and password='$password'";
$result = mysql_query($query);
if(mysql_num_rows($result) !=0){
$num=mysql_fetch_array($query);
$_SESSION['username'] = $num['username'];
$_SESSION['password'] = $num['password'];
$_SESSION['status'] = $num['status'];
if($num['status'] =='Enable'){
header("Location: home.php");
}
}else{
echo"Mungkin Akun Anda Dalam Status Disable";
echo"<a href='login.php'>Silahkan Login!</a>";
}
?>