Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Multiple PHP forms on one page

Featured Replies

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.

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

  • 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.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.