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 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 43

Thread: Login Page

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

    Latest Awards:

    Default

    PHP Code:
    <?php 

    ////////// You need to GRAB the array for the information
    $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']; 
             
            
    ////////// needs the array of data to check against.....
            
    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" />


    www.fragme.co = a project.

  2. #12
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Would this be correct?

    PHP Code:
    <?php 

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

    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" />

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

    Latest Awards:

    Default

    @Source; Oh right, thanks.


  4. #14
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    I just tested it and yeah, it works. Now it just gives me an error regarding the header. The "can't modify headers, bla bla bla".

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

    Latest Awards:

    Default

    PHP Code:
    <?php
    //w/e includes
    include "config.php";

    if(
    $_GET['do'] == 'login'){
            
        
    //get the info from post
        
    $user $_POST['username'];
        
    $password $_POST['password'];
        
        
    // grab any rows with that username and pass and count the rows returned
        
    $userQ mysql_query("SELECT * FROM `users` WHERE `username` = '$user' and `password` = '$password");
        
    $userC mysql_num_rows$userQ );
        
        
    // if it returns 1 then the details must of been correct
        
    if( $userC == ){
             
    $_SESSION['username'] = $user;
             
    $_SESSION['logged_in'] = 1;
             
    header("Location: index.php");
        } else {
            echo 
    "Sorry the information you provided was wrong";
        }
        
        
    }

    <
    form method="post" action="?do=login">
    <
    input type="text" name="username" />
    <
    input type="password" name="password" />
    <
    input type="submit" value="login" />
    </
    form>
    ?>
    Wrote it up super quick, so soz for any errors. But that seems more logical to me? Also disclaimer would be "Make sure in the released version all inputs are filtered blah blah blah, and maybe try mysql sessions rather than browser sessions... blah blah"

    also even that is a bad login, as it can easily be spoofed (changing your session logged_in to 1). Anyway, the main idea was to recreate what you already have.
    Last edited by Source; 16-11-2008 at 09:08 PM.


    www.fragme.co = a project.

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

    Default

    Thanks Matt, last thing: I get this when I try to use headers:
    Warning: Cannot modify header information - headers already sent by (output started at /home/x/public_html/test/login.php:11) in /home/x/public_html/test/login.php on line 17

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

    Latest Awards:

    Default

    Is session_start etc... right at the top of your config.php and executed before any other information is sent to the browser?


    www.fragme.co = a project.

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

    Default

    Yes, it is.

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

    Latest Awards:

    Default

    well unfortuantly I don't have time to read through all of your script etc... maybe make a new thread with it all in for other members to have a widdle.


    www.fragme.co = a project.

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

    Default

    Alright, thanks for all your help.

Page 2 of 5 FirstFirst 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
  •