asher - 2008-01-03 21:06:01 -
In reply to message 1 from Thukbir Makhani
hai
im a begineer im stuck in this error for the past 3 hrs pls help
mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\index.php on line 28
asher
-------------------------------------------------------------------------------
<?php
session_start();
session_destroy();
$message="";
$Login=$_POST['Login'];
if($Login){
$username=$_POST['username'];
$md5_password=md5($_POST['password']);
$host="localhost";
$db_user="root";
$db_password="";
$database="tutorial";
$db=mysql_connect($host,$db_user);
mysql_select_db($database,$db);
// Check matching of username and password.
$srch="select * from admin where username='$username' and password='$md5_password'";
$result=mysql_query($srch,$db);
$num_rows = mysql_num_rows($result);
if($num_rows!='0') { // If match.
session_register("username"); // Craete session username.
header("location:main.php"); // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}
} // End Login authorize check.
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo $message; ?>
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
<table>
<tr>
<td>User : </td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
<input name="Login" type="submit" id="Login" value="Login" />
</form>
</body>
</html>