mrt003003 Posted May 3, 2011 Share Posted May 3, 2011 Hi there, i have code that enables a user to login to my site. I have a player table that consists of: PlayerName, Password and Status. The playername and password is what logs the user in however i want to make it so that when a user logs in it automatically sets that users Status to 1. Can some one point me in the right direction please?? Thanks <?php if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['textfield'])) { $loginUsername=$_POST['textfield']; $password=$_POST['textfield2']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "index.php"; $MM_redirectLoginFailed = "fail.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_swb, $swb); $LoginRS__query=sprintf("SELECT PlayerName, Password FROM player WHERE PlayerName=%s AND Password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $swb) 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']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Thank you Quote Link to comment https://forums.phpfreaks.com/topic/235450-login-and-set-status-value/ Share on other sites More sharing options...
spiderwell Posted May 3, 2011 Share Posted May 3, 2011 just after the login success, you need to execute an sql update setting Status to 1 something like: "UPDATE player SET `status` = 1 WHERE PlayerName=%s AND Password=%s" Quote Link to comment https://forums.phpfreaks.com/topic/235450-login-and-set-status-value/#findComment-1210086 Share on other sites More sharing options...
mrt003003 Posted May 3, 2011 Author Share Posted May 3, 2011 Thats brilliant thank you! I used the following just after //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; <?php $updateSQL = sprintf("UPDATE player SET Status = '1' WHERE PlayerName = %s", GetSQLValueString($_POST['status'], "text" ), GetSQLValueString($loginUsername, "text")); mysql_select_db($database_swb, $swb); $Result1 = mysql_query($updateSQL, $swb) or die(mysql_error()); ?> Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/235450-login-and-set-status-value/#findComment-1210087 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.