PHP - Detect Auto Form Submission

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spickles
Forum Newbie
Posts: 1
Joined: Sun Jul 05, 2009 8:54 pm

PHP - Detect Auto Form Submission

Post by spickles »

Can anyone tell me how to detect a form that was auto-submitted using JavaScript? I can easily detect manual form submissions with the 'isset' method. But I have a form that is submitted using JavaScript document.forms[0].submit(). How can I detect this on the server side using PHP?

Regards,
Scott
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Re: PHP - Detect Auto Form Submission

Post by Skara »

Have a hidden field and change the value when it autosubmits.
e.g.

Code: Select all

<input type="hidden" id="autosubmit" name="autosubmit" value="0" />
...
document.getElementById('autosubmit').value = "1";  //something like this, I'm a little rusty on my javascript...
document.forms[0].submit();
Post Reply