Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts

    session just doesnt seem to start...

    hey..
    i posted a while back about sessions.. and found some stuff
    i have this code now.. but it doesnt seem to work... i include this code on the top of my pages i wana protect but it just asks for pass and user name even after youve loged in..
    any ideas why it dont work?
    cheers
    heres the code...
    Code:
    <?php // accesscontrol.php
    
    session_start();
    
    if(!isset($uid)) {
      ?>
      <html>
      <head>
      <title> Please Log In for Access </title>
      </head>
      <body>
      <h1> Login Required </h1>
      <p>You must log in to access this area of the site. If you are
         not a registered user, <a href="signup.php">click here</a>
         to sign up for instant access!</p>
      <p><form method="post" action="login.php">
        User ID: <input type="text" name="username" size="8"><br>
        Password: <input type="password" name="password" SIZE="8"><br>
        <input type="submit" value="Log in">
      </form></p>
      </body>
      </html>
      <?php
      exit;
    }
    
    session_register("username");
    session_register("password");
    
    dbConnect("sessions");
    $sql = "SELECT * FROM user WHERE
            username = '$username' AND password = PASSWORD('$password')";
    $result = mysql_query($sql);
    if (!$result) {
      error("A database error occurred while checking your ".
            "login details.\\nIf this error persists, please ".
            "contact support\@tabberstemple.com");
    }
    
    if (mysql_num_rows($result) == 0) {
      session_unregister("username");
      session_unregister("password");
      ?>
      <html>
      <head>
      <title> Access Denied </title>
      </head>
      <body>
      <h1> Access Denied </h1>
      <p>Your user ID or password is incorrect, or you are not a
         registered user on this site. To try logging in again, click
         <a href="<?=$PHP_SELF?>">here</a>. To register for instant
         access, click <a href="signup.php">here</a>.</p>
      </body>
      </html>
      <?php
      exit;
    }
    
    $username = mysql_result($result,0,"fullname");
    ?>
    sir p

  • #2
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you getting any error messages ? i used to have the same problem when i installed AbriaSoft Merlin Server ... and the solution was to created a tmp directory in the root of the drive it was installed.

    HormonX

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    umm no..it doesnt error.. just doesnt seem to start/register the session..
    any further thoughts?
    im using apahce btw
    cheers bud
    sir p

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    lookin over again i think ive found my prblem.
    in the dbConnect("sessions");
    i`l go test somthing when i get back and get back to you if it doesnt change.
    cheers
    P


  •  

    Posting Permissions

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