Jump to content


Photo

Limit form submissions to X amount of tries


  • Please log in to reply
7 replies to this topic

#1 Dave96

Dave96
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 March 2006 - 06:47 AM

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

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 24 March 2006 - 10:08 AM

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.
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 Dave96

Dave96
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 26 March 2006 - 09:44 PM

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)?

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 March 2006 - 10:09 PM

[!--quoteo(post=358663:date=Mar 26 2006, 09:44 PM:name=Dave96)--][div class=\'quotetop\']QUOTE(Dave96 @ Mar 26 2006, 09:44 PM) View Post[/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.


if($submit) {
if($usierid ==3)
{
echo"sorry you used our form wrong there times!";
exit;
}else{
if(userid<3){
submit info
}
}


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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Dave96

Dave96
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 26 March 2006 - 10:41 PM

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!

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 March 2006 - 11:30 PM

maybe you can hold the users ip in a session and then do the if 3 times without a database dont no.

good quistion
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 March 2006 - 11:56 PM

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.

<? 
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">


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 27 March 2006 - 11:03 AM

[!--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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users