November 30, 201015 yr Hi, I wondered if someone could please help. I have a page, index.php, that has two different forms collecting different information. The PHP code for the first form is on the page, as this form was here first. I've just added the second but its action it references to another page, contact.php so when the submit button is pressed, it executes the code on that page. Only problem is, when I press submit, the page appears to be executing the PHP code on index.php. In other words it seems to be submitting both forms and as a result I'm getting validation errors on a form I don't want to submit. How can you make it so that this doesn't happen! Jon.
November 30, 201015 yr I would say you need to submit each form to a seperate php file. e.g. index.php submits 1st form to contact.php and returns result then index.php submits 2nd form to info.php. so depending on the form submitted on the page, it would submit the info to the different form (contact.php or info.php) Can you show the source code?
November 30, 201015 yr Author Thanks for replying. My source code is a bit messy right now where I've been trying a few bits. I've decided to link to a new page and put the form there instead but thanks for offering your help. Jon.
November 30, 201015 yr I would say you need to submit each form to a seperate php file. e.g. index.php submits 1st form to contact.php and returns result then index.php submits 2nd form to info.php. so depending on the form submitted on the page, it would submit the info to the different form (contact.php or info.php) Can you show the source code? Not needed all u have to do is do a check to see if the first forms submit button was clicked if it was not it wont run that php code for the first form even if the second one was clicked u can do the check like this <?php if(isset($_POST['first_submit'])){ //Php code to run for form 1 } ?> Where it says first_submit thats the name of the submit button for, form 1
Create an account or sign in to comment