duanqian9503 2013-12-12 16:07
浏览 371

如何将电子邮件发送到隐藏输入字段中提供的电子邮件地址?

I've got a simple PHP email form. This is going to be used for multiple people, so in order to make it easier for people, I have a hidden input field in my html form that is basically the "mailTo" email address.

How do I get the email to send the email to the address provided in the hidden input field?

Here's my HTML:

<div id="formholder">
    <form method="post" action="http://www.artofliz.com/hosting/php/process.php">
        <!-- THE CLIENT'S EMAIL TO ADDRESS GOES HERE!!! -->
        <input name="to" type="hidden" value="lroberts@platinumstrategies.com" />

        <label for="name">Name</label>
        <input name="name" placeholder="Full Name" type="text" />

        <label for="email">Email</label>
        <input name="email" placeholder="youremail@example.com" type="email" />

        <label for="phone">Phone</label>
        <input name="phone" placeholder="XXX-XXX-XXXX" type="tel" />

        <input id="submit" name="submit" type="submit" value="Submit" />
    </form>
</div>

Here is my PHP handler:

<?php
    $to = $_POST['to'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];

    $from = 'From: noreply@platinumstrategies.com';
    // $to = 'lroberts@platinumstrategies.com';
    $subject = 'Free Guide Download';

    $body = "From: $name
 Email: $email
 Phone: $phone";

    if ($_POST['submit']) {
      /* Anything that goes in here is only performed if the form is submitted */
      if (mail ($to, $subject, $body, $from)) {
        echo '<p>Your message has been sent!</p>';
      } else {
        echo '<p>Something went wrong, go back and try again!</p>';
      }
    }
?>

http://pastebin.com/cqZP949r - Additionally, I should note that the 'to' that's commented out works fine. It's what I'm trying to do currently that's broken.

Thank you very much for your help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2024-五一综合模拟赛
    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口