Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9

Thread: Login Page

  1. #1
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default Login Page

    PHP Code:
    <?php
    session_start
    ();
    include (
    "global.php");


    $d mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND password = '$password'");
    $data mysql_fetch_array($d);

    if(
    $ologged == "1"){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['action'] == login){
            
    $user $_POST['username'];
            
    $user htmlspecialchars($user);
            
    $password $_POST['password'];
            
    $password htmlspecialchars($password);
            
    $password md5($password);
            
            if(
    $user == $data['username'] || $password == $data['password']){
                if(
    $data['activated'] == "no"){
                    echo 
    "Sorry but you have not activated your account yet. Please activate it by going to your inbox or if you have not received the email you can <a href=\"login.php?action=resendemail\">resend it.</a>";
                } else {
                 
    $_SESSION['user'] = $user;
                
    $_SESSION['loggedin'] = 1;
                
    header("Location: index.php");
                }
            } else {
                echo 
    "Your login credentials are incorrect.";
            }
        }
    }
    ?>
    <form action="?action=login" method="POST">
    <input type="text" name="username" value="Username" />
    <input type="password" name="password" value="password" />
    <input type="submit" value="login" />
    </form>
    My problem is that even though you enter the right credentials it says that they're incorrect. Thanks.
    Last edited by wsg14; 17-02-2009 at 02:25 AM.

  2. #2
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by wsg14 View Post
    PHP Code:
    <?php
    session_start
    ();
    include (
    "global.php");


    $d mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND password = '$password'");
    $data mysql_fetch_array($d);

    if(
    $ologged == "1"){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['action'] == login){
            
    $user $_POST['username'];
            
    $user htmlspecialchars($user);
            
    $password $_POST['password'];
            
    $password htmlspecialchars($password);
            
    $password md5($password);
            
            if(
    $user == $data['username'] || $password == $data['password']){
                if(
    $data['activated'] == "no"){
                    echo 
    "Sorry but you have not activated your account yet. Please activate it by going to your inbox or if you have not received the email you can <a href=\"login.php?action=resendemail\">resend it.</a>";
                } else {
                 
    $_SESSION['user'] = $user;
                
    $_SESSION['loggedin'] = 1;
                
    header("Location: index.php");
                }
            } else {
                echo 
    "Your login credentials are incorrect.";
            }
        }
    }
    ?>
    <form action="?action=login" method="POST">
    <input type="text" name="username" value="Username" />
    <input type="password" name="password" value="password" />
    <input type="submit" value="login" />
    </form>
    My problem is that even though you enter the right credentials it says that they're incorrect. Thanks.
    Well yes that would be because you're doing a mysql query before any variables are set.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #3
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    PHP Code:
    <?php
    session_start
    ();
    include (
    "global.php");

    $user $_POST['username'];
    $user htmlspecialchars($user);
    $password $_POST['password'];
    $password htmlspecialchars($password);
    $password md5($password);

    $d mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
    $data mysql_fetch_array($d);

    if(
    $ologged == "1"){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['action'] == "login"){
            
            if(
    $user == $data['username'] || $password == $data['password']){
                if(
    $data['activated'] == "no"){
                    echo 
    "Sorry but you have not activated your account yet. Please activate it by going to your inbox or if you have not received the email you can <a href=\"login.php?action=resendemail\">resend it.</a>";
                } else {
                 
    $_SESSION['user'] = $user;
                
    $_SESSION['loggedin'] = 1;
                
    header("Location: index.php");
                }
            } else {
                echo 
    "Your login credentials are incorrect.";
            }
        }
    }
    ?>
    <form action="?action=login" method="POST">
    <input type="text" name="username" value="Username" />
    <input type="password" name="password" value="password" />
    <input type="submit" value="login" />
    </form>
    It is still saying that the credentials are incorrect.

  4. #4
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by wsg14 View Post
    PHP Code:
    <?php
    session_start
    ();
    include (
    "global.php");

    $user $_POST['username'];
    $user htmlspecialchars($user);
    $password $_POST['password'];
    $password htmlspecialchars($password);
    $password md5($password);

    $d mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
    $data mysql_fetch_array($d);

    if(
    $ologged == "1"){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['action'] == "login"){
            
            if(
    $user == $data['username'] || $password == $data['password']){
                if(
    $data['activated'] == "no"){
                    echo 
    "Sorry but you have not activated your account yet. Please activate it by going to your inbox or if you have not received the email you can <a href=\"login.php?action=resendemail\">resend it.</a>";
                } else {
                 
    $_SESSION['user'] = $user;
                
    $_SESSION['loggedin'] = 1;
                
    header("Location: index.php");
                }
            } else {
                echo 
    "Your login credentials are incorrect.";
            }
        }
    }
    ?>
    <form action="?action=login" method="POST">
    <input type="text" name="username" value="Username" />
    <input type="password" name="password" value="password" />
    <input type="submit" value="login" />
    </form>
    It is still saying that the credentials are incorrect.
    Your credentials are incorrect then. There's nothing wrong with that code.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  5. #5
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    I've tried over 10 different user combinations, none work. There must be something wrong that is slipping past us.

  6. #6
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Just found something that would be part of the problem but it's still saying credentials are incorrect, here's the fix: (the query had a variable which didn't exist)

    PHP Code:
    <?php
    session_start
    ();
    include (
    "global.php");

    $user $_POST['username'];
    $user htmlspecialchars($user);
    $password $_POST['password'];
    $password htmlspecialchars($password);
    $password md5($password);

    $d mysql_query("SELECT * FROM users WHERE username = '$user' AND password = '$password'");
    $data mysql_fetch_array($d);

    if(
    $ologged == "1"){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['action'] == "login"){
            
            if(
    $user == $data['username'] || $password == $data['password']){
                if(
    $data['activated'] == "no"){
                    echo 
    "Sorry but you have not activated your account yet. Please activate it by going to your inbox or if you have not received the email you can <a href=\"login.php?action=resendemail\">resend it.</a>";
                } else {
                    
    $_SESSION['user'] = $user;
                    
    $_SESSION['loggedin'] = 1;
                    
    header("Location: index.php");
                }
            } else {
                echo 
    "Your login credentials are incorrect.";
            }
        }

    ?>
    <form action="?action=login" method="POST">
    <input type="text" name="username" value="Username" />
    <input type="password" name="password" value="password" />
    <input type="submit" value="login" />
    </form>

  7. #7
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    When you registered the user you did md5 the password yes? You probably did, but when I made my first ever system, that was my problem for ages because I didn't understand how it worked :p
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  8. #8
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Yes on the register page it md5's the password.

  9. #9
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Thanks to Iszak, he figured out the problem (wasn't the code, twas my column's varchar length).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •