Jump to content

Problem with login session


kts

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.