Page 1 of 1

I'm Stuck - need help

Posted: Sat Oct 23, 2004 3:11 am
by C++Casey
Hi I have some code that limits the user to a certain number of logins. Each time a user logs in it records a "credit" to the database. Once the total credits reach 5 then the user no longer has access to the member area. My code does everything except limit the user to the 5 login attempts. Can someone help me write the code that will limt the user to the 5 login attempts. Here is my code.

Code: Select all

<?
$updateSQL = mysql_query("SELECT credits FROM USERS WHERE username='$loginUsername'");
	if ($updateSQL >5) {
	echo "Number of credits have exceeded 5";
	}
	else {
$addCredit= "UPDATE USERS SET credits=credits+1 WHERE username='$loginUsername'";
	}
             
  	mysql_select_db($database_Users, $Users);
  	$Result1 = mysql_query($addCredit, $Users) or die(mysql_error());

?>

Posted: Sat Oct 23, 2004 6:51 am
by sakaveli
if ($updateSQL >5) {
echo "Number of credits have exceeded 5"; }
after your echo try putting :

die();


which should stop any further script being executed

Posted: Sat Oct 23, 2004 7:11 am
by C++Casey
That kills everything and the program wont get to the user that has less than 5....thanks for your effort though...keep the help coming

Posted: Sat Oct 23, 2004 8:52 am
by sakaveli
if the die statement is inside the IF then the script will only stop if the condition is met (more than five hits), if the user has less than 5 hits then the browser will skip the IF.

Posted: Sat Oct 23, 2004 9:12 am
by timvw
might want to reset to 0 if login has succeeded.