Dave96 Posted March 24, 2006 Share Posted March 24, 2006 Hi all,I'd like to limit a form submission to X amount of tries but I'm unsure on how to go on with this.For example, a form is submited but it throws an error. I'd like that if the error is thrown 3 times than it would give a message and disable the form.Best way to explain this is with a credit card form. Disable the form after 3 tries to avoid fraudsters "testing" their stolen cards.I will really appreciate any sort of answer!Thanks Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/ Share on other sites More sharing options...
shocker-z Posted March 24, 2006 Share Posted March 24, 2006 You could use sessions or IP address and then basicaly when the error is generated also add to a errors table and just add either session and do a count each time, and then on 3rd attempt it adds the ipaddress to a banned user list else you could just use the IPaddress and once it see's it 3 times in the list it's classed as blocked. and set a time/date so you can block for a certain period. Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-20208 Share on other sites More sharing options...
Dave96 Posted March 26, 2006 Author Share Posted March 26, 2006 Thanks shockerI'd like to know if there's a way of doing this without any database (since the form doesn't use any)? Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-20975 Share on other sites More sharing options...
redarrow Posted March 26, 2006 Share Posted March 26, 2006 [!--quoteo(post=358663:date=Mar 26 2006, 09:44 PM:name=Dave96)--][div class=\'quotetop\']QUOTE(Dave96 @ Mar 26 2006, 09:44 PM) [snapback]358663[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks shockerI'd like to know if there's a way of doing this without any database (since the form doesn't use any)?[/quote]If the user is in website that they goto loginto and then i would use the users session id, but if its a form that has no login system then i would use sessions as advised above.This is how i would use the if ststement if i wanted to users form of 3 times tried submissions.[code]if($submit) {if($usierid ==3){echo"sorry you used our form wrong there times!";exit;}else{if(userid<3){submit info}}[/code]If you have no database or flat file database then i got no idear sorry.//warning the code is probly wrong as i am a learner but its an idear ok. Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-20978 Share on other sites More sharing options...
Dave96 Posted March 26, 2006 Author Share Posted March 26, 2006 Is it possible to have a session with a value which auto-inrements on each POST?POST #1 -> the session value is 1...POST #3 -> the session value is 3Than if ($_SESSION['var'] == 3){echo "Too many tries";}If only I knew how to create such a value in the session.I tried operators ($x++), loops, everything. Maybe it's not possible?Any help appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-20991 Share on other sites More sharing options...
redarrow Posted March 26, 2006 Share Posted March 26, 2006 maybe you can hold the users ip in a session and then do the if 3 times without a database dont no.good quistion Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-21006 Share on other sites More sharing options...
redarrow Posted March 26, 2006 Share Posted March 26, 2006 why issent it working please help why issint the echoed message working when press the button 3 times please help.remember no database involved thank you all.[code]<? session_start(); // start The session$domain = GetHostByName($REMOTE_ADDR); //Get users ip addressecho $domain; //error reporting cheek if address is there for testing$domian=('$usersip');// session domain what athe users ip = form useripif (isset($submit)) {if($domain==3) {echo"you posted three times ok";}}?><form method="post" action=""><input type="text" name"<?$usersip?>" value=""><input type="submit" value="submit">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-21017 Share on other sites More sharing options...
shocker-z Posted March 27, 2006 Share Posted March 27, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<? session_start(); // start The sessionif (!$_SESSION['count']) {$_SESSION['count']=0;}if ($_POST['submit']) {$session_count=$_SESSION['count'];$session_count++;if($session_count>3) {echo"You have reached the limit!";exit;} elseif ($session_count<=3) {echo("submitting data..");}echo("setting session to: ".$session_count);$_SESSION['count']=$session_count;} else {?><form method="post" action=""><input type="text" name"" value=""><input type="submit" name="submit" value="submit"><?php } ?>[/quote]Try that i tested and is working on mine.. only thing is that all they have to do is exit the site and then they gone 3 more trys Quote Link to comment https://forums.phpfreaks.com/topic/5666-limit-form-submissions-to-x-amount-of-tries/#findComment-21142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.