【问题标题】:HTML -- PHP to EmailHTML -- PHP 到电子邮件
【发布时间】:2014-10-12 17:59:35
【问题描述】:

不确定我这样做是否正确。对这些东西完全陌生...我有一个多步骤表单,我正试图将其提交到我的电子邮件中。表单在每个阶段都有一组按钮。我希望将所选按钮发送到我的电子邮件。

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

【问题讨论】:

  • 感谢大家的意见!我通过添加一个在用户单击按钮时更新的隐藏字段来解决这个问题。代码如下。再次感谢!

标签: php html multi-step


【解决方案1】:

为此,您应该使用“选择”html 标记。所以用户可以选择他的选项,然后一键提交表单:

<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>

然后您可以检索用户选择的课程值:

$course = $_POST['course']); // Either "math" or "science" here

【讨论】:

    【解决方案2】:

    使用formaction属性

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 2015-11-26
      • 2016-06-10
      • 2014-08-26
      • 2012-04-28
      • 2011-03-04
      • 1970-01-01
      相关资源
      最近更新 更多