Hi everyone,

Im making a game that requires a login.

Ive got stuck on a problem;

When a user tries to log in, it wont accept it, its in the database, the script checks the database, but it still says no

Here is my login check:

<?
session_start();
header("Cache-control: private");
include 'includes/db_connect.php';



if (!$_SESSION['username'] || !$_SESSION['email']){
$username = $_POST['username'];
$password = $_POST['password'];
$username = strip_tags($username);
$password = strip_tags($password);
$ip = $REMOTE_ADDR;
$domain = $_SERVER['REMOTE_ADDR'];

$username=strtolower($username);

if((!$username) || (!$password)){
    echo "You have not submitted one or more fields <br />";
}else{




$sql = mysql_query("SELECT * FROM user_info WHERE username='$username' AND password='$password' LIMIT 1");
$login_check = mysql_num_rows($sql);



if ($login_check > '1'){





        ini_set(session.cookie_lifetime, "3600");
        session_register('username');
        $_SESSION['username'] = $username;
        session_register('email_address');
        $_SESSION['email_address'] = $email_address;






         $timestamp = time();
$timeout = $timestamp-$timeoutseconds;
$cool = gmdate('Y-m-d h:i:s');
mysql_query("UPDATE user_info SET lastlogin='$cool' WHERE username='$username'");
mysql_query("UPDATE user_info SET online='$timestamp' WHERE username='$username'");

mysql_query("UPDATE user_info SET ip='$domain' WHERE username='$username'");



        ?>
<meta http-equiv="Refresh" content=0;url=index.php>
<?

} else {
    echo "wrong username/password combination or account not yet activated<br />
    <br />";
    include 'splash.php';
}}}
?>

You can see an example here: craigs-space.freehostia/rm/splash.php

The register works, so you can create accounts

or use:

Username
64b9e88b

It will come up with a problem, i dont know whats causing it :s

any help would be appreciated

Member Avatar for diafol

SHouldn't your check be

if( mysql_num_rows(...) > 0)...

I dont get you

The site not working (demo).
Do you mean you can't login like the information not correct ?

Member Avatar for diafol

Instead of if ($login_check > '1'){ , write:

if ($login_check > 0){

Ahh of couse, thanks ardav :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.