Hi,
I'm having difficulty writing a query for a login.php page.
The query i've written doesn't seem to retrieve any results from the database. The query is as follows,
$myquery = "SELECT * FROM users WHERE userName = '" . $user;
$myquery .= "' AND password = '" . crypt($password, "DWMXPHP") . "'";
$result = mysql_query($myquery);
if (!$result)
{
$error = "Cannot run query";
return($error);
}
$numRows = mysql_num_rows($result);
if ($numRows < 1)
{
$error = "User name or password not recognised";
return($error);
}
Whenever I try to login, the error "User name or password not recognised" which emplies that the query is not retrieving any results.
I'm using the same encrypt key to both INSERT and SELECT the data and all the variable/function/object names correspond.
Any idea's whats wrong with my code?
Thanks in advance,
Nick