I'm Stuck - need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
C++Casey
Forum Newbie
Posts: 10
Joined: Sun Oct 17, 2004 4:38 am

I'm Stuck - need help

Post 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());

?>
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post 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
C++Casey
Forum Newbie
Posts: 10
Joined: Sun Oct 17, 2004 4:38 am

Post 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
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

might want to reset to 0 if login has succeeded.
Post Reply