Jump to content

Recommended Posts

<?php
if (isset($_POST['button'])) {
$user = $_POST['user'];
$pass = $_POST['pass'];
$db = mysql_connect("localhost","root",""); 
mysql_select_db("users",$db);
$rezz = mysql_query("select * from usrs where username = '$user' and password = PASSWORD('$pass')");

if (!$db ) {	exit(mysql_error());	}

if (mysql_num_rows($rezz) == "1") {
	echo "good";

} else {		$errorMsg = "user/pass incorrect";			}


}



?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <label>username
  <input type="text" name="user" id="user" />
  </label>
  <p>
    <label>password
    <input type="text" name="pass" id="pass" />
    </label>
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Submit" />
</p>
</form>

</body>
</html>
<?php
if (isset($_POST['button'])) {
if (mysql_num_rows($rezz) == "0") {
	echo $errorMsg;
}
}


?>

 

in this code

 

$rezz = mysql_query("select * from usrs where username = '$user' and password = PASSWORD('$pass')");

this doesn`t work

if doesnt grab the pass from the database...

it works if the password if uncrypted

$rezz = mysql_query("select * from usrs where username = '$user' and password = '$pass' ");

 

| adv1  | *B12E45A418E975B0269 |

| adv2  | shit1                |

second works

what could be wrong

in the database i have encripted the password with PASSWORD() function of sql

 

 

Link to comment
https://forums.phpfreaks.com/topic/104014-solved-database-error/
Share on other sites

If the second one works then I would assume your password was never stored properly in the database and was stored as plaintext.  I'd start by looking at your create user function.  You could switch your queries to

 

$sql = "select * from usrs where username = '$user' and password = PASSWORD('$pass')";
$rezz = mysql_query($sql);

 

This way you can easily go into the function and do a:

print($sql)

to see if the mysql query is running properly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.