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 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default PHP Help - mySQL & Sessions

    First Problem

    For some reason mysql_fetch_array(); is showing up as an invalid function.

    http://daniel.valvi.co.uk/thf/login_check.php

    I'm not sure what the problem is...

    Second Problem

    Never used sessions before. What should I do in order to ensure the security of my application when using sessions? Should I clean the session variables, should I regenerate a session after each login, etc.
    Vouches
    [x][x]

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

    Latest Awards:

    Default

    Post the code.

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

    Latest Awards:

    Default

    PHP Code:
    $username clean($_POST['username']);
    $password clean(encrypt($_POST['password']));
    $result mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); 
    $row mysql_fetch_array($result); 
    $id $row['id']; 
    $select_user mysql_query("SELECT * FROM users WHERE id='$id'"); 
    $row2 mysql_fetch_array($select_user); 
    $user $row2['username']; 
    $get_level mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'");
    $row5 mysql_fetch_array($get_level);
    $level $id['level'];
    $pass_check mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'"); 
    $row3 mysql_fetch_array($pass_check); 
    $select_pass mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'"); 
    $row4 mysql_fetch_array($select_pass); 
    $real_password $row4['password']; 
    That's login_check.php

    Config.php which is require_once'd in the code contains the db conn.

    PHP Code:
    $db_name 'localhost';
    $db_user 'removed for security purposes';
    $db_pass 'removed for security purposes';
    $conn mysql_connect($db_name,$db_user,$db_pass);
    $dbconn1 mysql_select_db('removed for security purposes'$conn); 
    Vouches
    [x][x]

  4. #4
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    I cant help you with your first problem but for sessions,
    - Make sure you destroy all sessions when the person closes the browser
    - Definately create new sessions on login and dont add a remember me function if you are that bothered
    - Make sure that session ID' arent in the browser link, if your using them in the links
    - if youve given people a session before they log in, make sure that you assign them a new one when they do log in.

    LOL i probably havent helped. lol
    Back for a while

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

    Latest Awards:

    Default

    - Make sure you destroy all sessions when the person closes the browser
    Doesn't that happen automatically?

    - Definately create new sessions on login and dont add a remember me function if you are that bothered
    Yep already done that.
    - Make sure that session ID' arent in the browser link, if your using them in the links
    How would I do that?

    - if youve given people a session before they log in, make sure that you assign them a new one when they do log in.
    Thanks
    Vouches
    [x][x]

  6. #6
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Fazon View Post
    PHP Code:
    $username clean($_POST['username']);
    $password clean(encrypt($_POST['password']));
    $result mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); 
    $row mysql_fetch_array($result); 
    $id $row['id']; 
    $select_user mysql_query("SELECT * FROM users WHERE id='$id'"); 
    $row2 mysql_fetch_array($select_user); 
    $user $row2['username']; 
    $get_level mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'");
    $row5 mysql_fetch_array($get_level);
    $level $id['level'];
    $pass_check mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'"); 
    $row3 mysql_fetch_array($pass_check); 
    $select_pass mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'"); 
    $row4 mysql_fetch_array($select_pass); 
    $real_password $row4['password']; 
    That's login_check.php

    Config.php which is require_once'd in the code contains the db conn.

    PHP Code:
    $db_name 'localhost';
    $db_user 'removed for security purposes';
    $db_pass 'removed for security purposes';
    $conn mysql_connect('$db_name','$db_user','$db_pass');
    $dbconn1 mysql_select_db('removed for security purposes'$conn); 
    Edited. Sessions are easy to secure. You could just use a little function for that:

    PHP Code:
    function cleanme($string) {
    $string htmlspecialchars($string);
    $string mysql_real_escape($string);
    $string stripslashes($string);
    return 
    $string;

    Plus, make sure there is actually data in the database.
    Last edited by Excellent2; 11-02-2009 at 12:02 AM.
    Back for a while.

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

    Latest Awards:

    Default

    Quote Originally Posted by Excellent2 View Post
    Edited. Sessions are easy to secure. You could just use a little function for that:

    PHP Code:
    function cleanme($string) {
    $string htmlspecialchars($string);
    $string mysql_real_escape($string);
    $string stripslashes($string);
    return 
    $string;

    Plus, make sure there is actually data in the database.
    That's a ridiculous function, it undoes whatever you do. I could quite easily type in

    Code:
    ' OR 1=1--
    and have it walk straight though.


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

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

    Latest Awards:

    Default

    Yeah I know how to clean the session but what should I do to prevent session stealers?

    And what exactly did you edit? I can't see a difference.
    Vouches
    [x][x]

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

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    That's a ridiculous function, it undoes whatever you do. I could quite easily type in

    Code:
    ' OR 1=1--
    and have it walk straight though.
    I thought ' OR 1=1-- gets blocked my mysql_real_escape??

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

    Latest Awards:

    Default

    Quote Originally Posted by Blinger View Post
    I thought ' OR 1=1-- gets blocked my mysql_real_escape??
    stripslashes removes what mysql_real_escape does


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

Page 1 of 2 12 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
  •