Link to home
Start Free TrialLog in
Avatar of jackie777
jackie777

asked on

form with two submit buttons to php

Hi
I am trying to write a html form so that it outputs its field data to two separate parts of a php document which then handles the data depending on which submit button has been selected. Im hoping some has a few ideas as to how I can accomplish this. Here is some code explaining what I am trying to do.

<FORM name=form action="form_data.php" method=post>
data field 1 <input type="text" name="data1" >
data field 2 <input type="text" name="data2" >
data field 3 <input type="text" name="data3" >
<input type="submit" name="Submit1" value="Submit">
<!-- if this button is clicked it should go to and run section 1 of form_data.php-->
<input type="submit" name="Submit2" value="Submit2">
<!-- if this button is clicked it should go to and run section 2 of form_data.php-->
</form>

form_data.php

<?php
$data1 = $_POST_VARS['data1'];
$data2 = $_POST_VARS['data2'];
$data3 = $_POST_VARS['data3'];
//here is where I dont know how to separate the data into two sections
// section 1 -- when the Submit1 button is clicked this should run
echo $data1;
echo $data2;
echo $data3;
// section 2 -- when the Submit2 button is clicked this should run
echo $data3;
echo $data2;
echo $data1;

?>
ASKER CERTIFIED SOLUTION
Avatar of etully
etully

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial