1

I am trying to create a check list that allows users to check off each item they want and then send an email to their chosen email. I am using JQueryMobile and I don't know if it's causing any problems, but the page just keeps on loading continuously when I press submit.

This is my HTML code:

<form name="emailform" enctype="multipart/form-data" action="form-to-email.php" method="post">
  <div data-role="fieldcontain">
  <label for='name'>Festival name: </label><br>
  <input type="text" name="name">
   <h3>
   Essentials
   </h3>


   <fieldset data-role="controlgroup" data-type="vertical">
    <legend>
    </legend>
    <input name="checkbox1" id="checkbox1" type="checkbox" />
    <label for="checkbox1">
    Tickets
    </label>
    <input name="checkbox2" id="checkbox2" type="checkbox" />
    <label for="checkbox2">
    Parking pass
    </label>
    <input name="checkbox3" id="checkbox3" type="checkbox" />
    <label for="checkbox3">
    Directions
    </label>
    <input name="checkbox4" id="checkbox4" type="checkbox" />
    <label for="checkbox4">
    Cash &amp; Cards
    </label>
    <input name="checkbox5" id="checkbox5" type="checkbox" />
    <label for="checkbox5">
     Keys
    </label>
    </fieldset>

     <label for='email'>Send to Email:</label><br>
     <input type="text" name="email">

     <input name="share" type="submit" value="Share">

     </form>

And this is my PHP:

    <?php
    if(!isset($_POST['submit'])){
    if (!$_POST['name'] | !$_POST['email']) 
    {
    echo"<div class='error'>Error<br />You did not fill in a required field, please       review your form and correct the missing information.</div>";
    }
    }
    $name = $_POST['name'];
    $email = $_POST['email'];
    $checkbox1 = $_POST['checkbox1'];

    $email_from = "Application";
    $email_subject = $name;
    $email_body = "You have received a new checklist via App.\n".
    "Here is the checklist so far:\n $checkbox1".

    $headers = "From: $email_from \r\n";
    mail($email, $email_subject,$email_body,$headers);
    header('Location: index.html');

    ?>
4

2 回答 2

0

如果您尝试从 localhost 发送电子邮件,那么您肯定会遇到此错误,因为默认情况下没有邮件设置。但是,您可以在您的计算机上安装一个测试邮件服务器来测试来自 localhost 的电子邮件。

如果您从实时服务器发送电子邮件,那么您需要按照本教程来克服代码中可能存在的任何问题:http: //www.w3schools.com/php/php_mail.asp

于 2012-12-04T12:26:53.707 回答
0

我认为您应该通过 AJAX 与 jQuery 进行通信,在这种情况下您不应该发送标头。您还应该注意复选框值是 TRUE/FALSE,所以

“您已通过 App 收到一份新的清单。”。“这是迄今为止的清单:”。

于 2012-12-04T12:39:21.477 回答