Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.