Jump to content

Limit form submissions to X amount of tries


Dave96

Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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 shocker

I'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.
Link to comment
Share on other sites

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 3

Than

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!
Link to comment
Share on other sites

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 address

echo $domain; //error reporting cheek if address is there for testing

$domian=('$usersip');// session domain what athe users ip = form userip

if (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]
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?
session_start(); // start The session
if (!$_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
Link to comment
Share on other sites

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.