
Originally Posted by
DJHolliday
I'm missing a line here.
Something like:
'$count = mysql_num_rows($result)'
Otherwise I don't see any relation between your SQL Statement and your $count variable.
But maybe I'm missing something else here.
True.
And there's something wrong with the query string too. You start the string with a single quote, and close it with a double quote when you want to add the $name and $password. Just use double quotes at the beginning and the end of the whole string. That way PHP will substitute the two variables with their value:
PHP Code:
$sql = "SELECT * FROM registered_members WHERE name='$name' and password='$password'";
Another thing: never use user inserted values in your queries without validation:
PHP Code:
$name=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
One last thing (though maybe the book will talk about that later on): never save passwords in plaintext. Save them encrypted, for example using the MD5 function.
In that case, you would have something like this to get the $password:
PHP Code:
$password=md5(mysql_real_escape_string($_POST['password']));