www.webdeveloper.com
Results 1 to 2 of 2

Thread: login and check they are in

  1. #1
    Join Date
    Jun 2003
    Location
    London
    Posts
    14

    login and check they are in

    having some difficulty with this, here is the setup.

    page1. html form with username and pass input.

    page2. validate username and pass with sql table have link to page 3

    page3. check login status.


    Now for page 2 i used:
    <?
    $pass = md5($pass);
    include 'db.php';

    $sql = "select * from staff where username='$uname' and password='$pass'";
    $result = mysql_query($sql);
    if(mysql_num_rows($result)!=0)
    { echo "we have a match";
    $_SESSION['loggedin']=true;

    }
    else
    {
    echo "error";
    }

    ?>


    And for page3 i used:

    <?
    session_start();
    if ($_SESSION['loggedin'])
    {
    echo 'you are logged in ...';
    }
    else
    {
    echo 'error';
    }
    ?>

    But if i remove the $_SESSION['loggedin']=true; from page 2, page 3 gives me a "you are logged in" message, is there any other simpler way of doing this or am i doing something wrong? Also is there a way of setting an idle time, so say of there isnt any activity for say 2mins then the user is logged out automatically and taken to page1.

    Many thanks

    ceanth

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    On page 2, you should be doing something like this:

    PHP Code:
    session_start();
    session_register ("loggedin"); 
    rather than this:
    PHP Code:
    $_SESSION['loggedin']=true

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles