Reputation: 368
I have this function in class called User
/**
* Function to get everything about specific user
* @access public
* @param string that user's email
* @param string that user's password
*/
public static function selectUser ( $email, $password )
{
$result = mysql_query ( ' SELECT * FROM `modernt_mtalk`.`users` WHERE Email = ' . $email . ' AND Password = ' . md5($password) );
if($result) {return $result;}
else {return false;}
}
and i call it in other file
require_once 'user.php';
$user = new User();
$info = $user -> selectUser('[email protected]', 'root');
echo $info;
I put that data in so i can test if echo $info
would give me anything. but that echo does nothing.
I know that it's not wrong data in ()
because i have other function that i tested with the same data and it works fine.
What's wrong?
Upvotes: 0
Views: 54
Reputation: 45500
Here's how you call a static function, you shouldn't encrypt the parameter since the function already does this for you:
$info = User::selectUser('[email protected]', 'root'); //no need to encrypt twice
Also the query doesn't look correct, since email and password are not integers, they will need to be quoted:
$result = mysql_query ("SELECT * FROM `modernt_mtalk`.`users` WHERE Email = '". $email ."' AND Password = '". md5($password)."'");
Upvotes: 1
Reputation: 2207
That's because you parse already encrypted password which I suspect you shouldn't encrypt since you also encrypt it in your query so the method returns false. var_dump
the result or display the "incorrect logins" if the method returns false
require_once 'user.php';
$user = new User();
if($info = $user -> selectUser('[email protected]', 'root'))
echo $info;
else
echo 'Incorrect details';
Upvotes: 0