SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Return from include...

    I have a main page that 'includes' a login.php that basically processed users logging into the page. The problem I'm having is that anything after the 'include' on the default.php page fails to load until the user sucessfully logs in... I'm sure I missed something very rudimentary here, but I just can't spot it.... I've included the code below... please let me know if you see the problem...

    PHP Code:
    <?
    if (!isset($uid)) {
    ?>
    <table width="100%" cellpadding="0" cellspacing="0" border="0" style="border:1px solid black; background-color: white">
     <tr>
      <td class="logtop">
      
       Family Login:
      
      </td>
     </tr>
     <tr>
      <form method="post" action="<?=$_SERVER['PHP_SELF']?>?page=<?=$page?>">
      <td class="logbot">
      
       Username:<br>
       <input type="text" size="20" name="uid"><br>
       
       Password:<br>
       <input type="password" size="20" name="pwd"><br><br>
       
       <input type="submit" value="Login!" style="border: 1px solid silver; color: #7E98CC"><br><br>
       
       <a href="default.php?page=privacy" onmouseover="window.status='Privacy Policy'; return true">Privacy Policy</a><br>
       <a href="register.php">Sign Me Up!</a><br><bR>
      
      </td>
      </form>
     </tr>
    </table>
    <?
    exit;
    }
    $_SESSION['uid'] = $uid;
    $_SESSION['pwd'] = $pwd;
    dbConnect($db_name);
    $sql "SELECT * FROM tbl_users WHERE userid = '$uid' and password = '$pwd'";
    $result mysql_query($sql);
    if (!
    $result) {
     
    error ('A database error occurred while checking your login credentials. '.
        
    'If this error persists, please contact $admin_email');
    }
    if (
    mysql_num_rows($result) == 0) {
     unset (
    $_SESSION['uid']);
     unset (
    $_SESSION['pwd']);
     
    ?>
     
    <table width="100%" cellpadding="0" cellspacing="0" border="0" style="border:1px solid black; background-color: white">
     <tr>
      <td class="logerror">
      
       Access Denied!
      
      </td>
     </tr>
     <tr>
      <td class="errbot">
      
       The User ID or Password you entered is incorrect, or you are not authorized to access this site.<br><br>
       To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. <br><br>
       To obtain access, contact <a href="<A href='mailto:<?=$admin_email?>"></a>.mailto:<?=$admin_email?>"><?=$admin_email?></a>.<br>
         
      </td>
     </tr>
    </table> 
    <?
    }
    else {
    ?>
    <table width="100%" cellpadding="0" cellspacing="0" border="0" style="border:1px solid black; background-color: white">
     <tr>
      <td class="logtop">
      
       Welcome Back:
      
      </td>
     </tr>
     <tr>
      <td class="logbot">
      
       <?=$uid;?>
       <br><br>
       
       <a href="default.php?page=privacy" onmouseover="window.status='Privacy Policy'; return true">Privacy Policy</a><br>
       <a href="" onMouseOver="window.status='Log Out';return true" onMouseOut="window.status='';return true" onClick="<? session_unset(); session_destroy(); ?>">Log Out</a>
         
      </td>
     </tr>
    </table>
    <?
    }
    ?>

  2. #2
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can post the default.php if you need to see how it's referenced. just fyi.

  3. #3
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you've been following Kevins article on session management, as I have, and it looks about right Brian.

    You're not supposed to see anything else until the user has logged in correctly.
    Lats...

  4. #4
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No.. this form is actually included on all pages so the user can log in at any time so i still need the rest of the page to display... if the user then browses to a secured area, he'll be forced to log in to see anything... that's the general idea. regardless though.. i found the problem... i replaced the Exit command with Return, and now all works as it should. thanks!


Bookmarks

Posting Permissions

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