The code for my login page is
<?php
//Database Information
$dbhost = "localhost";
$dbname = "no peeking";
$dbuser = "no peeking";
$dbpass = "no peeking";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
//Start the session
session_start();
//Store the information entered in the login form into variables
$username = $_POST['username'];
$password = md5($_POST['password']);
//Search for account in MySQL database
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysql_query($query);
$total = mysql_num_rows($result);
if (mysql_num_rows($result) != 1) {
echo "$total";
echo "There is no account with that username/password combination.";
include 'index.php';
}
else {
//Store the username in a session
$_SESSION['username'] = "$username";
include 'index.php';
}
?>
However what is returned with you log in with a correct username and password is:
0There is no account with that username/password combination.
I can only persume this means that the mysql_num_rows is returning "0" when it should be returning 1. Any idea what the problem is with this code?
See the page for yourself at:
www.sylvanas.net/dead
Username: Testing
Password: testing