Shilo Posted January 23, 2009 Share Posted January 23, 2009 <?php session_start(); $passpw = $_POST['password']; $userac = $_POST['username']; if ($action == 'login'){ $sql="SELECT * FROM user WHERE username = \"$userac\" AND password = \"$passpw\""; $result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); $num=mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $active = $row['active']; $confirm = $row['confirm']; $valid_user = $row['valid_user']; } if($active == "no") { $error = 'You have Been Banned From For Abuse On Our Forums!'; } if($confirm == "no"){ $error = "Your Email Address Hasnt Been Yet Confirmed!"; } elseif($active == "yes") { $_SESSION['valid_user'] = $valid_user; $error = 'Login Successful'; } elseif($passpw == NULL) { $error = 'You Did Not Enter A Password'; } elseif($userac == NULL) { $error = 'You Did Not Enter A Username'; } elseif($valid_user == NULL) { $error = 'You Entered Incorrect Login Information'; } } elseif ($action = 'logout'){ session_destroy(); } ?> For some reason the session will only stay registered on that page. Once I leave I lose the session data and my account logs out. I have session_start(); on everypage. but it still doesnt want to stay registered. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/142070-solved-session-wont-hold/ Share on other sites More sharing options...
Shilo Posted January 23, 2009 Author Share Posted January 23, 2009 Any Suggestions? Ive been trying to get this to work for like 3 hours. I got no clue whats wrong... :'( Link to comment https://forums.phpfreaks.com/topic/142070-solved-session-wont-hold/#findComment-744020 Share on other sites More sharing options...
Shilo Posted January 23, 2009 Author Share Posted January 23, 2009 I am such a retard! This is the error: <?php elseif ($action = 'logout'){ session_destroy(); } ?> Was supposed to be: <?php elseif ($action == 'logout'){ session_destroy(); } ?> 3 Hours!!! 3 hours and alot of stress. and 2 bottles of beer down the drain! For what? Just for 1 equals sign!! Link to comment https://forums.phpfreaks.com/topic/142070-solved-session-wont-hold/#findComment-744031 Share on other sites More sharing options...
jonsamwell Posted January 23, 2009 Share Posted January 23, 2009 Logic errors are alway the hardest to find. We've all been in exactly the same position at one time or another!! Link to comment https://forums.phpfreaks.com/topic/142070-solved-session-wont-hold/#findComment-744196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.