I have a php file which is gathering the username and password and checking it against the database, if it matches then the user logs on. Is it possible to get the ID of this row and store this in a variable ready for a session ?
I'm currently using this statement.
$query = mysql_query("select * from users where password='$password' AND username='$username'", $connection);
Thanks all
Yes, there is a way:
$query = mysql_query("select * from users where password='$password' AND username='$username'", $connection);
$row = mysql_fetch_array($query);
$id = $row['user_id']; //change user_id to the column name
But don't use mysql_*
, use mysqli_*
instead.