which form??

A

Anonymous

Guest
I have 2 forms feeding 2 different functions in the same script. how can i discern one from another when using the if($_SERVER['REQUEST_METHOD'] != 'POST') { to tell my php that a form is being used?

I beleive if I use something in the order of if ($_POST["somevar"] == "") { I get something in like varible not defined or something as one of the forms does not send this var the other one does.

Does this make any sence? I've confused myself on this one :D
 
Almost there LazyJones! You got it anyway :D
What will "define" that is the form submit buttons' names.
Example:
Code:
<?php

if(isset($_POST['FormOne'])) {
     print 'First from Submitted!';
}

if(isset($_POST['FormTwo'])) {
     print 'Second form Submitted!';
}

?>
<form name="f1" method="post" action"whatever">
  <input type="text" name="fname" value="">
  <input type="submit" name="FormOne" value="">
</form>

<form name="f2" method="post" action"whatever">
  <input type="text" name="fname" value="">
  <input type="submit" name="FormTwo" value="">
</form>
KillGorack said:
I beleive if I use something in the order of if ($_POST["somevar"] == "") { I get something in like varible not defined or something as one of the forms does not send this var the other one does.
This won't happen! If you don't submit a form... their data won't exist in the $_POST (or other) array. Which means, you'll only have in your $_POST array the data refered to the submitted form.
 
you guys are awesome.. this forum rocks.. that worked very nicely.. totally worked thanks :D
 
Back
Top