Do you have any idea what causes the warning message on this simple bit of code?
if(isset($_POST['remember']))
{
$query_cookie = ("SELECT id FROM users WHERE email = '$email' OR username = '$username'");
$result_cookie = mysql_query($query);
$row_cookie = mysql_fetch_array($result_cookie); // LINE 36
$id = $row_cookie; // Will be hashed before using
setcookie( "Remember", $id, strtotime( '+30 days' ) );
echo $id;
}
Here is the error that I got:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Signup\includes\login.php on line 36
The other problem that I have concerns my query. Basically I have a login form with three inputs: one for username, one for email, one for password. I want the user to be able to log in with either his username or password. However the query looks kinda weird to me and I wonder if it would work as expected, because the final query will end in something like this:
SELECT id FROM users WHERE email = 'user@host.com' OR username = ''
or the other way around. I guess this query is not fully functional. I'm open to suggestions if you have any.
$id is the same thing as $row_cookie atm because $id will be hashed. Would it be ok if I'd do a simple $id = sha1(md5($row_cookie)); ?
I know that MySQL is depreciated. I'll switch to MySQLi soon enough so no worries there.
As you can see there are actually three questions. If that's a problem please let me know before downrating so I can edit my question. Thanks!