-2

Not sure if I'm doing this right. Completely new to this stuff... I have a multistep form that I'm trying to get submitted to my email. The form has a set of buttons in each phase. I'd like the selected buttons to be sent to my email.

HTML:

<fieldset id="secondField">
    <h2 class="fs-title"> Select A Course</h2>
        <input type="button" name="course" class="next action-button" value="Math" />
        <input type="button" name="course" class="next action-button" value="Science" />
</fieldset>

PHP

<?php
   // from the form
   $course = trim(strip_tags($_POST['course']));
   $count = trim(strip_tags($_POST['count']));

 // set here
   $subject = "Course Request";
   $to = 'email';

   $body = <<<HTML
 COURSE: $course
 PARTICIPANTS: $count
  • Thanks everyone for the input! I got this one solved by adding a hidden field that updated when the user clicked a button. Code below. Thanks again!

    – Tristan St Louis Bruce Oct 14 '14 at 22:03

2 Answers2

0

You should use a "select" html tag for this purpose. So the user can select his options and then submit the form with pressing one button :

<fieldset id="secondField">
    <h2 class="fs-title"> Select A Course</h2>
    <select name="course" class="next action-button">
        <option value="math">Math</option>
        <option value="science">Science</option>
    </select>
    <input type="submit" value="Choose" />
</fieldset>

Then you can retrieve course value selected by the user :

$course = $_POST['course']); // Either "math" or "science" here
Yoric
  • 1,761
  • 2
  • 13
  • 15
0

use formaction attribute

<fieldset id="secondField">
    <h2 class="fs-title"> Select A Course</h2>
        <input type="submit" formaction="../next.php" name="course" class="next action-button" value="Math" />
        <input type="submit" formaction="../send.php" name="course" class="next action-button" value="Science" />
</fieldset>
ANZAWI
  • 79
  • 1
  • 5