I have two forms on the same page, each with different fields and different submit button names.
<button type="submit" name="formOne">Submit form</button>
<button type="submit" name="formTwo">Submit form</button>
On my mailer.php
page I would like to check which submit button has been clicked, and process the code accordingly.
The code I have so far works for a single form, as follows;
if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
// my form 1 data
// do stuff
}
However I thought I coulld add an if/else
to check which submit button was clicked, something like;
if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
if($_POST['formOne']){
// form 1 data
// my form 1 data
// do stuff
}
if($_POST['formTwo']){
// form 2 data
// my form 2 data
// do stuff
}
}
This doesn't seem to work. The error I receive is;
Notice: Undefined index: formOnein ... line 7
How can I achieve this?