Jump to content

Archived

This topic is now archived and is closed to further replies.

Dave96

Limit form submissions to X amount of tries

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
maybe you can hold the users ip in a session and then do the if 3 times without a database dont no.

good quistion

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.