kts Posted November 20, 2008 Share Posted November 20, 2008 Ok, I have 3 files working with this. One is a class doing the check one is the login.php and the other is the account.php Login: <?php // Form Submission if(isset($_POST['Submit'])){ $formemail = $_POST['email']; $formpass = md5($_POST['pass']); $newUser = new User; $newUser->userLogin($formemail, $formpass, $T_Login_Info); if($_SESSION['useremail'] == $_POST['email']){ header("Location:account.php"); //move to login.php todo } Class: function userLogin($formemail, $formpass, $T_Login_Info){ $sql = "SELECT * FROM $T_Login_Info WHERE email = '$formemail' AND pass = '$formpass'"; $result = mysql_query($sql) or die("userLogin error: ".mysql_error()); ; if(mysql_num_rows($result) > 0){ $_SESSION['useremail'] = $formemail; $_SESSION['userpass'] = md5($formpass); } else { $this->error = "invalid login"; unset($formeamil); unset($formpass); } return $_SESSION['useremail']; return $this->error; } And Account.php <?php // Declare the includes include('includes/variables.php'); include('classes/user.php'); include('includes/db.php'); // Check if the user is logged in if($_SESSION['useremail'] == ""){ //NOT LOGGED IN header("location:login.php"); The problem that occurs is on login.php i echo'd the session and its fine, but when i goto account i tried echoing it and nothing... I believe its going to account with proper email/pass, but then shooting back to login. Thanks! Link to comment https://forums.phpfreaks.com/topic/133448-problem-with-login-session/ Share on other sites More sharing options...
Goldeneye Posted November 20, 2008 Share Posted November 20, 2008 Where do you actually start the session in account.php? Link to comment https://forums.phpfreaks.com/topic/133448-problem-with-login-session/#findComment-694097 Share on other sites More sharing options...
kts Posted November 20, 2008 Author Share Posted November 20, 2008 wow.... i need sleep thanks, i mistakenly had it commented out! thanks a lot tho, give me a nice sleep Link to comment https://forums.phpfreaks.com/topic/133448-problem-with-login-session/#findComment-694098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.