Tech Talk : PHP – Handling Multiple Forms In One PageI have seen multiple ways to dealing with form submit, most of the times it is always to POST/GET the form to another PHP file? Uhhhhh… and file to maintain.
There is a more efficient way to deal with this… yes the grass is indeed greener on the other side of the fence.

One PHP page to do it all…”myExample.php”.
Below is a “myExample.php” file. I have added comments to help you our. I hope it is clear.

  if (!empty($_POST['contactSubmit'])) {
    // do ordering here

  if (!empty($_POST['contactSubmit'])) {
    //do contacting us process here
<form name="orderFromUs" method="post" action="join.php">
  <input type="text" name="desc" />
  <input type="text" name="qty" />
  <input type="submit" name="OrderSubmit" value="Send Email" />
<form name="contactUs" method="post" action="sendmail.php">
  <input type="text" name="email" />
  <input type="text" name="subjet" />
  <input type="submit" name="contactSubmit" value="Send Email" />

Note that you will have to use the submit button’s “name” to determine which form was submitted.