Jump to content

Login and set status value


mrt003003

Recommended Posts

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 :D

 

 <?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

Link to comment
https://forums.phpfreaks.com/topic/235450-login-and-set-status-value/
Share on other sites

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 :)

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.