lundi 20 avril 2015

POST form submits upon page load

I am creating an online form for multiple users to enter details into.

The problem occurs as follows: user fills out the form, and clicks submit. The inputs are transmitted to a php script via POST after validation. Inputs are appended to mySQL database via php in a separate script.

PHP directs to a new page, thanking the user for filing out the form. If an error occurred, this page alerts the user. This page provides a 'next user' button to redirect to index.php (containing the form) to allow another user to fill out the form.

This is where the problem occurs; the same thanking page is reloaded, alerting the user that an error occurred. Turns out that index.php loaded, submitted the form instantly, bypassing js validation, fails database entry, and directs the user to the thanking page.

Has anyone had this problem occur before? A POST form submitting itself when directed to? The strange thing is that when I enter the URL for the form, it loads perfectly. I've tried directing using tags and javascript; both fail.

Thanks for any help in advance. Rob

Aucun commentaire:

Enregistrer un commentaire