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!


Page 1 of 5 12345 LastLast
Results 1 to 10 of 43

Thread: Login Page

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

    Default Login Page

    PHP Code:
    <?php

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

    if(
    $grab_login === 1){
        
    header("Location: index.php");
    } else {
        if(
    $_GET['do'] == login){
            
    $user $_POST['username'];
            
    $password $_POST['password'];
            
            if(
    $user == $data['username'] || $password == $data['password']){
                
    $_SESSION['username'] = $user;
                
    $_SESSION['logged_in'] = 1;
                
    header("Location: index.php");
            } else {
                echo 
    "your login credentials were incorrect.";
            }
        }
    }
    ?>
    <form action="?do=login">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <input type="submit" value="login" />
    That is my login code, and it isn't working correctly. If I enter false credentials it doesn't give me the error. Also, when you click login, the url turns into "url.com/login.php?do=login&username=username&password=pass word. +rep

    Closed by Johno! (Forum Moderator): To prevent further pointless posting.
    Last edited by Johno; 18-11-2008 at 05:09 PM.

  2. #2
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    That login does not make any sense what so ever. We need to see it all, and if that is all of it... then wth.

    ref "the url turns into "url.com/login.php?do=login&username=username&password=pass " - add method="POST" to your form tag
    Last edited by Source; 16-11-2008 at 08:43 PM.


    www.fragme.co = a project.

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

    Default

    Why wth? I don't see anything wrong with it? There's a config.php include at the top of the page (not included in that code). If you want I can show config.php?

  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    PHP Code:
    <?php 

    //where is it getting $username from?
    $data mysql_query("SELECT * FROM `users` WHERE `username` = '$username'"); 

    //where is it getting $grab_login
    if($grab_login === 1){ 
        
    header("Location: index.php"); 
    } else { 
        if(
    $_GET['do'] == login){ 
            
    $user $_POST['username']; 
            
    $password $_POST['password']; 
            
            
    //$data['username'] doesnt correspond to anything? same with pass
            
    if($user == $data['username'] || $password == $data['password']){ 
                
    $_SESSION['username'] = $user
                
    $_SESSION['logged_in'] = 1
                
    header("Location: index.php"); 
            } else { 
                echo 
    "your login credentials were incorrect."
            } 
        } 

    ?> 

    answer those questions in comments.


    www.fragme.co = a project.

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

    Default

    All of those variables are defined in config.php.

  6. #6
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    Lol, epic fail.

    For my own curiosity, what difference does three ==='s mean?


  7. #7
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    all of them? so why have the query at the top and no fetch_array to go with it? At the moment its check the credentials with a resource return (or w/e ).

    And L?ke I believe 3 = (===) means the value and data type must be the same (integer, boolean etc..).


    www.fragme.co = a project.

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

    Default

    All of them but $data. Why do I need to use fetch_array?

  9. #9
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    because your using that information to see if the username and password are correct?

    This script is seriously confusing, and if its not then fair enough im an idiot.


    www.fragme.co = a project.

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

    Default

    PHP Code:
    <?php 

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

    // if logged in goto homepage, if not continue
    if($grab_login === 1){ 
        
    header("Location: index.php"); 
    } else { 
        if(
    $_GET['do'] == login){ 
            
    $user $_POST['username']; 
            
    $password $_POST['password']; 
             
            
    // checks if the username and password the user entered matches the ones in the database
            
    if($user == $data['username'] || $password == $data['password']){ 
                
    $_SESSION['username'] = $user
                
    $_SESSION['logged_in'] = 1
                
    header("Location: index.php"); 
            } else { 
                echo 
    "your login credentials were incorrect."
            } 
        } 

    ?> 
    <form action="?do=login"> 
    <input type="text" name="username" /> 
    <input type="password" name="password" /> 
    <input type="submit" value="login" />
    All I want to do is check if the information the user entered is correct (matches the ones in the database).

Page 1 of 5 12345 LastLast

Posting Permissions

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