Thank you for your quick reply. This is what i have so far:
Step #1 - Check loginThis is on my login.php page
<?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['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "CustomerPage.php";
$MM_redirectLoginFailed = "Login2.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_allison, $allison);
$LoginRS__query=sprintf("SELECT Username, Password FROM tblCustomer WHERE Username=%s AND Password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $allison) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//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 );
}
}
?>
Step 2 โ Determine the value of the logins column and add 1
The code I have is as follows and is located on the CustomerPage.php
<?php $cat = $row_rsUser['catID'];
$Curr = $row_rsUser['logins']+1;
if ($cat==2){
echo $row_rsUser['$Curr'];
} ?>
<input name="logins" type="text" id="logins" value="<?php echo $Curr?>">
Step 3 โ See if the login count is < than allowable limit
I have an onload javascript function that checks the value and delivers an alert if the number has been exceeded.
Step 4 โ Update the database column
This is where I am stuck. I cannot seem to get the code right and then not even sure where to put it. I know how to update the table using a submit button but this is not applicable in this case. I tried using the code below but it doesnโt work.
<?php
mysql_query("UPDATE tblCustomers SET logins = $Curr WHERE CustomerID = $row_rsUser['CustomerID']"); ?>
what am I doing wrong?