Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql_num_rows() expects parameter 1 to be resource, boolean given in
- if ($_POST['submit'])
- {
- $username = $_POST['id'];
- $password = $_POST['pass'];
- //connect to the database here
- $username = mysql_real_escape_string($username);
- $query = "SELECT hashpass, salt
- FROM users
- WHERE username = '$username'";
- $result = mysql_query($query);
- if(mysql_num_rows($result) < 1) //no such user exists
- {
- echo "NO USER!";
- }
- $userData = mysql_fetch_array($result, MYSQL_ASSOC);
- $hash = sha1 ( $userData['salt'] . $password );
- if($hash != $userData['password']) //incorrect password
- {
- echo "WRONG PASS";
- }
- }
- $result = mysql_query($query);
- if ($result)
- {
- if(mysql_num_rows($result) == 1)
- {
- // user exists... check password
- }
- else
- {
- //no such user exists
- echo "NO USER!";
- }
- }
- else
- {
- // Query failed - no such user
- }
- int mysql_num_rows ( resource $result )
- <?php
- $link = mysql_connect("localhost", "mysql_user", "mysql_password");
- $query = "SELECT hashpass, salt
- FROM users
- WHERE username = '$username'";
- $result = mysql_query($query);
- mysql_select_db("database", $link);
- $result = mysql_query($query, $link);
- $num_rows = mysql_num_rows($result);
- if($num_rows < 1) //no such user exists
- {
- echo "NO USER!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement