Page 1 of 1

Localhost x Godaddy servers error

Posted: Tue Mar 03, 2015 2:26 pm
by madson_gr
Hi,

I have a login/register system based on this tutorial: http://pt.wikihow.com/Criar-um-Script-d ... HP-e-MySQL

In my localhost everything works fine. When I uploaded it to godaddy servers, I can register the new user but I cannot login into the users' pages. It looks like password or salt does not match, or after compare login data, it´s telling me the message: You don´t have permission to see this page, please login.

Do you have any idea of what might be? Godaddy support told me they cannot help. They just fix their own services.

Thanks in advance.

Re: Localhost x Godaddy servers error

Posted: Tue Mar 03, 2015 8:04 pm
by requinix
In login_check(), after $stmt->store_result(), put

Code: Select all

$stmt->bind_result($password);

Re: Localhost x Godaddy servers error

Posted: Tue Mar 03, 2015 11:32 pm
by madson_gr
same thing...this already exists inside if(...) below that...

Re: Localhost x Godaddy servers error

Posted: Wed Mar 04, 2015 1:52 pm
by requinix
No, it's not there already.

You say you added it? What is the code now?

Re: Localhost x Godaddy servers error

Posted: Thu Mar 05, 2015 1:21 am
by madson_gr
yes I did like you said but nothing has changed
Look where I've commented

Code: Select all


function login_check($mysqli) {
    // Check if all session variables are set 
    if (isset($_SESSION['user_id'], 
                        $_SESSION['username'], 
                        $_SESSION['login_string'])) {
 
        $user_id = $_SESSION['user_id'];
        $login_string = $_SESSION['login_string'];
        $username = $_SESSION['username'];
 
        $user_browser = $_SERVER['HTTP_USER_AGENT'];
 
        if ($stmt = $mysqli->prepare("SELECT password 
                                      FROM members 
                                      WHERE id = ? LIMIT 1")) {
            // Bind "$user_id" to parameter. 
            $stmt->bind_param('i', $user_id);
            $stmt->execute(); 
            $stmt->store_result();
            $stmt->bind_result($password);  // HERE IS WHAT YOU SAID
 
            if ($stmt->num_rows == 1) {
                $stmt->bind_result($password);   // HERE THE EXISTING CODE
                $stmt->fetch();
                $login_check = hash('sha512', $password . $user_browser);
 
                if ($login_check == $login_string) {
                    // Logged In!!!! 
                    return true;
                } else {
                    // Not logged in 
                    return false;
                }
            } else {
                // Not logged in 
                return false;
            }
        } else {
            // Not logged in 
            return false;
        }
    } else {
        // Not logged in 
        return false;
    }
}