Hello, I'm looking for someone to fix a simple php problem. I have a script where users signup. They later can login and change their person information like name/email etc. For some reason when the user logs in, it just goes to the default user #1 instead of the user that logs in. I'm willing to pay $15 via Paypal if anyone can work with me to fix this problem. Thanks!
Ok here is the login php script: <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['email'])) { $loginUsername=$_POST['email']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "myAccount.php"; $MM_redirectLoginFailed = "login_failed.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_SQLConnection1, $SQLConnection1); $LoginRS__query=sprintf("SELECT email, password FROM login_table WHERE email=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $SQLConnection1) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Here is the Account php script <?php require_once('../Connections/SQLConnection1.php'); //initialize the session session_start(); if (! isset($_SESSION['MM_Username'])){ header("location: supplier_login.php"); exit; } $id = $_SESSION['MM_Username']; /////////////////////////////////////////// $query = sprintf("SELECT * FROM login_table WHERE login_table.email"); $result = @mysql_query($query); $rowAccount = @mysql_fetch_array($result); ///////////////////////////////////////// ?>
I m ready to fix the problem If I have whole code so that I can simulate on my system and test it. PM me if interested !!!
$query = sprintf("SELECT * FROM login_table WHERE login_table.email"); that is the problem line. it should be something like $query = sprintf("SELECT * FROM login_table WHERE login_table.username = '%s'",$id); PHP: I'm not too sure what your username field is called, but you need to change .username to whatever it is in your table and it should work
For some reason it's still not working. I think that it needs the following: The script needs to set a session variable that can be carried over/remebered through out the users session.