Asperon Posted July 26, 2007 Share Posted July 26, 2007 so the forms showed up the first time....but after that it won't work, I don't know if the session isn't destoying or what, I checked the recent post http://www.phpfreaks.com/forums/index.php/topic,151696.0.html for destroy sessions problems. I don't know what is wrong. I've been going over it for the past half an hour. its probably something dumb, but I can' seem to find it. the logout displays the array() and logged out data, so I know the sessions is destroyed. login.php: <?php session_start(); if (isset($_POST['userName']) && isset($_POST['password'])) { $userName = $_POST['userName']; $password = $_POST['password']; //connect to database $link = mysql_connect('localhost', 'testUser', 'sra259') or die('Could not connect: ' . mysql_error()); mysql_select_db('iluvsocaldb') or die('Could not select database'); $query = 'SELECT * FROM administratorlogin WHERE userName="$userName" AND password="$password"'; $result = mysql_query($query); $numRows = mysql_num_rows($result); if($numRows > 0) { $_SESSION['validUser'] = $userName; } mysql_close($link); } ?> <html> <head> <title>ADMIN LOG IN</title> </head> <body> <? if(isset($_SESSION['validUser'])) { echo $_SESSION['validUser'] } else { if (isset($userName)) { echo 'Could not log you in.<br />'; } else { echo 'You are not logged in.<br />'; } echo '<form action="logIn.php" method="POST">'; echo '<table>'; echo '<tr>'; echo '<td>User Name</td>'; echo '<td><input type="text" name="userName" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Password</td>'; echo '<td><input type="password" name="password" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td><input type="submit" value="LOG IN" /></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; } ?> <br/> <a href="db_admin.php">Admins Only</a> <a href="logout.php">Log Out</a> </body> </html> db_admin.php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head></head> <body> <?php session_start(); if(isset($SESSION['validUser'])) { echo '<h3><center>Welcome to the iluvsocal database editor</center></h3>'; echo '<table align="center">'; echo '<tr>'; echo '<td>'; echo '<form action="view_business.php" target="iframe" method="post">'; echo '<input type="submit" value="Businesses" />'; echo '</form>'; echo '</td>'; echo '<td>'; echo '<form action="view_salesRep.php" target="iframe" method="post">'; echo '<input type="submit" value="Sales Reps" />'; echo '</form>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '<iframe name="iframe" src="default.php" height="800" width="800" frameborder="0" allowtransparency="true"></iframe>'; } else { echo '<h3>You are not authorized to view this page</h3>'; } ?> </body> </html> logout.php: <?php session_start(); session_destroy(); print_r($_SESSION); if(empty($_SESSION)){ ?> <html> <body> <p>logged out</p> <a href="logIn.php">blahblah</a> </body> </html> <?php } ?> Quote Link to comment Share on other sites More sharing options...
Trium918 Posted July 26, 2007 Share Posted July 26, 2007 Could you be more specific. What is the problem that you are having with the script? Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 the first time I ran it , the login form appeared like it was supposed to, because no session had started, so I logged in, and it went to the db_admin.php page..that page didn't work, I probably still need to fix something I missed there, so i went back and I did the logout, according to the script output, it destoyed the session, but the logIn.php file will not longer dispaly the form, it which means that it still thinks its logged in. Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 the first time I ran it , the login form appeared like it was supposed to, because no session had started, so I logged in, and it went to the db_admin.php page..that page didn't work, I probably still need to fix something I missed there, so i went back and I did the logout, according to the script output, it destoyed the session, but the logIn.php file will not longer dispaly the form, it which means that it still thinks its logged in. I fixed the db_admin.php problem, that page says i'm logged out too, but the login page won't show the form still. Quote Link to comment Share on other sites More sharing options...
Trium918 Posted July 26, 2007 Share Posted July 26, 2007 Trying clearing the cache then reload the file. If you are able to see the login page, the session isn't being destroyed. Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 still nothing, and now...for some reason when I click logout, the address bar changes to the /logout.php but the page itself does nothing Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 fixed the logout problem, but the session still seems to continue....sigh....... Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 the login and log I got to work now, but when I try to go the db_admin page it says I'm not authorized... Quote Link to comment Share on other sites More sharing options...
Asperon Posted July 26, 2007 Author Share Posted July 26, 2007 I Fixed it all thanks for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.