Jump to content

[SOLVED] I have run out of ideas of how to debug.


maxudaskin

Recommended Posts

I made this script yesterday, but I cannot seem to debug a crucial error. I put letters and numbers into the functions so I know what exactly it is doing and in what order. Everything seems to be logically correct, but it is not seeming to complete the functions as a whole properly.

 

http://www.virtualzoom.net/loginscript/

Username: test

Password: test123

 

Code:

http://www.virtualzoom.net/loginscript/pretty/

Now I am getting the following error with the following code.

 

MySQL Error 1054 with description Unknown column 'test' in 'where clause'

 

$sql   = "SELECT password FROM " . USERS_TABLE . " WHERE username = " . $username;
$query = mysql_query($sql) or die ( "MySQL Error " . mysql_errno() . " with description " . mysql_error() );

All values in a query must be wrapped in quotes

 

$sql = "SELECT password FROM " . USERS_TABLE . " WHERE username = '$username'";

 

Also on your index page, session_start must be called before any output is made:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <?php include ("include/login.php"); session_start(); ?>

Should be

<?php include ("include/login.php"); session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Now I am getting the following error with the following code.

 

MySQL Error 1054 with description Unknown column 'test' in 'where clause'

 

$sql   = "SELECT password FROM " . USERS_TABLE . " WHERE username = " . $username;
$query = mysql_query($sql) or die ( "MySQL Error " . mysql_errno() . " with description " . mysql_error() );

 

uhhh... dude $username is a string it needs to be in quotes

 

also are you sure its a good idea to store someone's username + password together in a cookie?.....

Ok, well it is still not working. Test it out and tell me what you think please.

 

It works at first, but if you refresh (do not resend POST data) or reenter the URL, it doesn't work.

 

I think it may be sessions.

Change your confirmUser function to

// Check Credentials
function confirmUser($username, $password)
{
    // undo magic cuotes
    if (get_magic_quotes_gpc())
    {
        $username = stripslashes($username);
    }

    // escape harmful characters
    $username = mysql_real_escape_string($username);

    // md5 'n salt the password
    $password = md5($password . SALT);

    // check the username AND password in the query at the same time
    $sql = "SELECT username FROM " . USERS_TABLE . " WHERE username = '$username' AND password = '$password'";
    $query = mysql_query($sql) or die("MySQL Error " . mysql_errno() . " with description " . mysql_error());

    // check that mysql returned 1 result, meaning a match was found
    if (mysql_num_rows($query) == 1)
    {
        return TRUE;
    }

    // no match return false!
    return FALSE;

}

Here is the list.

 

Notice: Undefined variable: PHP_SELF in /home/.grable/vzoom/virtualzoom.net/loginscript/include/functions.php on line 79

Notice: A session had already been started - ignoring session_start() in /home/.grable/vzoom/virtualzoom.net/loginscript/index.php on line 1

 

 

After Login

Notice: Undefined variable: password in /home/.grable/vzoom/virtualzoom.net/loginscript/include/login.php on line 178

 

Notice: Undefined index: remember_me in /home/.grable/vzoom/virtualzoom.net/loginscript/include/login.php on line 181

 

Notice: A session had already been started - ignoring session_start() in /home/.grable/vzoom/virtualzoom.net/loginscript/index.php on line 1

You are logged in

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.