hi... I wrote a login.php, but when i submit i receive a warning like this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\login.php on line 16
What is that? And it is not working properly, what i want.😕
Hasan S.
Here is the code :
//HTML Form to log in...
<form action="login.php" method="post">
Username <input type="text" name="username"><br />
Password <input type="password" name="pass"><br />
<input type="submit" name="submit" value="login"></form>
<? //end of form ?>
<?
if(isset($submit)){
#check if account exists
$qstring="SELECT * FROM uyebilgiler WHERE kullaniciadi = '".$POST['username']."' AND parola = '".$POST['pass']."'";
echo "SQL Statement: ".$qstring;
$qry = mysql_query($qstring);
$numrows = mysql_num_rows($qry);
if($numrows < 1){ // If no return fr. database, the account doesn't exist....
}else{
session_start(); // start the session...
$SESSION['username'] = $POST['username']; // Registers the session user.
echo $_SESSION['username']; //just control
checklog();
}
//End of Validating
}
//The Check log
function checkLog(){
global $_SESSION;
if(session_is_registered("username")){
#add code to validate the user in the db
}else{
session_unregister("username"); // unregister the session
header("location: index.php"); // send them to the "home page"....
}
}
?>