Shoutbox

Php coding help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Php coding help (/showthread.php?tid=29609)

Php coding help by king_of_cool_kids on 08-07-2004 at 05:35 AM

Ok. I have a contact form on my site, and have a JavaScript code to stop multiple submitting in one go. However, recently I have been getting lots and I think it may be because people have JavaScript turned off in their browser. I was talking to a friend this morning, and he said that the same effect could be done using php, and that it is more secure and reliable.

So:

a) Is this true

b) If so, how can I go about implementing it on my site??

Thanks in advance.


RE: Php coding help by WDZ on 08-07-2004 at 05:55 AM

That javascript probably only works until the page is refreshed... someone could send one, refresh the form, paste the message back in, send another, and so on.

quote:
Originally posted by king_of_cool_kids
a) Is this true
PHP being more secure and reliable than javascript? Yes, definitely.

quote:
Originally posted by king_of_cool_kids
b) ... how can I go about implementing it on my site??
You want to stop the same person from submitting 2+ messages in a row? Does your contact script store anything on the server or just send an e-mail? If nothing is stored, the easiest method is probably setting a cookie, but that's not really secure, because the submitter could reject or delete it.

A more secure method of duplicate-checking would be storing the submitter's IP address on the server (in a text file or database) and then checking/updating it next time a submission is made.
RE: Php coding help by king_of_cool_kids on 08-07-2004 at 06:16 AM

ok, well, basicly, I want something (php) that will disable the submit button once clicked, and have a time span of 3 mins between submitions.

Database available if needed.


RE: Php coding help by WDZ on 08-07-2004 at 06:30 AM

quote:
Originally posted by king_of_cool_kids
ok, well, basicly, I want something (php) that will disable the submit button once clicked
Hmm... well, because PHP is server-side, it can't disable the submit button right away like javascript can. The user would have to reload the form before the submit button could be disabled. :-/

quote:
Originally posted by king_of_cool_kids
and have a time span of 3 mins between submitions.
Are you sure that's enough? Someone could spam you with almost 20 messages per hour if they were determined... :p

If you use the cookie-based method, you could simply set a cookie with a 3-minute expiration time. With the other method, you'd have to store a time on the server along with the IP.
RE: Php coding help by king_of_cool_kids on 08-07-2004 at 06:36 AM

a) Whats an fast, reliable option to stop people from submitting lots of times??

b) Cookies can be deleted easily. I want something that cant be. Any ideas??

c) PM me if you can, its easier to keep track of


RE: Php coding help by KeyStorm on 08-07-2004 at 08:58 AM

Well, you can user sessions to do that, although people could keep restarting their browsers to override that.

If you're keeping track of the usernames and the date and time they last posted, it's not very difficult to stop them from submitting in 3 minutes.


RE: Php coding help by king_of_cool_kids on 08-09-2004 at 05:13 AM

ok, so how do I go about (in php or another reliable coding) setting up anything to stop people from submitting things lots of times in one go by either disabling the button, or whatever?? So long as they cant click, click, click heaps of times, then im happy.

Edit: Ok, I talked to my friend again this morning. He said that session would be good and easy, but if I wanted an easier way, make a script that will prevent a user from clicking the button, as it would be greyed out with the words "Need Javascipt on to use form" if they didn't have javascript on.

Does anyone know any way of coding this type of thing??


RE: Php coding help by -dt- on 08-09-2004 at 06:43 AM

if i remember right the noscript tag will display whats inside it insted of  the javascript if scripts are off 

code:
<noscript> test </noscript>

RE: Php coding help by king_of_cool_kids on 08-09-2004 at 06:56 AM

??? Im talking about a script that tests if Javasciprt is enabled. If so, lets the form be processed, if not, on loading the page, make the submit button grey with the words "Need Javascipt on to use form"


RE: Php coding help by ddunk on 08-09-2004 at 07:10 AM

http://www.webaim.org/techniques/javascript/alternatives - Read 4.2 Using the <noscript> Element, including the Example


RE: Php coding help by king_of_cool_kids on 08-09-2004 at 10:33 PM

Thanks Ddunk. I am now using this code:

code:
<script type="text/javascript">
<!--
document.write('<input type="button" value="Submit" onclick="validateForm();">');
-->
</script>
<noscript><center>Sorry, you need javascript<br>turned on to use this form</noscript>
It works for accedental spam,

But still, for spammers, all they have to do is load the page, then turn javascript off. Does anyone know of a code to make it check javascript is on after the user clicks submit, not when the page loads?? Solved by Chris Boulton over at the myBB comunity. Thanks everyone for you help.