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 4 of 4

Thread: [PHP] More Help

  1. #1
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default [PHP] More Help

    I have tried every usersystem tut there is on the net and I have also tried myself many times but nothing works. Here's Naresh's usersystem from techtuts (edited quite a bit of course).

    Lets start with the login page. It doesn't work. For some reason clicking login just refreshes the page.

    Source:
    PHP Code:
    <?php
    ob_start
    ();
    include(
    'config.php');
    if (!
    $logged['username']) {
     if (!
    clean($_POST['login'])) {
      echo(
    '
      <form method="post" enctype="text/plain">
      Username: <br />
      <input type="text" maxlength="30" name="l_username"> <br /><br />
      
      Password: <br />
      <input type="text" maxlength="30" name="l_password"> <br /><br />
      
      <input type="submit" value="Login" name="login"> <br /><br />
      </form>
      <a href="register.php">Register</a> | Forgot Passowrd
      
      '
    );
      }
      
     if (
    $_POST['login']) {
      
    $username clean($_POST['l_username']);
      
    $password encrypt(clean($_POST['l_password']));
      
      
    $info mysql_query("SELECT * FROM users WHERE username = '$username'");
      
    $data mysql_fetch_array($info);
      
      if(
    $data['password'] != $password) {
       echo 
    'The username and/or password you entered was incorrect.';
      } else {
       
    $query mysql_query("SELECT * FROM users WHERE username = '$username'");
       
    $user mysql_fetch_array($query);
       
       
    setcookie('id'$user['id'],time()+(60*60*24*5), "/""");
       
    setcookie('pass'$user['password'],time()+(60*60*24*5), "/""");
       echo 
    'Thanks for logging in <b>'.$logged['username'].'</b>. Click <a href="index.php">here</a> to return to the main page.';
      }
      }
    } else {
     echo 
    'You are already logged in. Click <a href="index.php">here</a> to return to the main page.';
    }
    ?>
    Vouches
    [x][x]

  2. #2
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    What is that
    PHP Code:
    clean($_POST['login')) 
    crap?

    Try this:

    PHP Code:
    <?php
    ob_start
    ();
    include(
    'config.php');
    if (!
    $logged['username']) {

      
     if (
    $_POST['login']) {
      
    $username clean($_POST['l_username']);
      
    $password encrypt(clean($_POST['l_password']));
      
      
    $info mysql_query("SELECT * FROM users WHERE username = '$username'");
      
    $data mysql_fetch_array($info);
      
      if(
    $data['password'] != $password) {
       echo 
    'The username and/or password you entered was incorrect.';
      } else {
       
    $query mysql_query("SELECT * FROM users WHERE username = '$username'");
       
    $user mysql_fetch_array($query);
       
       
    setcookie('id'$user['id'],time()+(60*60*24*5), "/""");
       
    setcookie('pass'$user['password'],time()+(60*60*24*5), "/""");
       echo 
    'Thanks for logging in <b>'.$logged['username'].'</b>. Click <a href="index.php">here</a> to return to the main page.';
      }
      } else {
      echo(
    '
      <form method="post">
      Username: <br />
      <input type="text" maxlength="30" name="l_username"> <br /><br />
      
      Password: <br />
      <input type="text" maxlength="30" name="l_password"> <br /><br />
      
      <input type="submit" value="Login" name="login"> <br /><br />
      </form>
      <a href="register.php">Register</a> | Forgot Passowrd
      
      '
    );
      }
    } else {
     echo 
    'You are already logged in. Click <a href="index.php">here</a> to return to the main page.';
    }
    ?>

  3. #3
    Join Date
    Feb 2009
    Location
    London
    Posts
    935
    Tokens
    100
    Habbo
    Sameer!

    Latest Awards:

    Default

    Wait, are you trying to connect to a MySQL database where the usernames and password is stored?

  4. #4
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    The clean() functions and database connection are all in config.php. I'll try that Blinger.
    Vouches
    [x][x]

Posting Permissions

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