-1

提前感谢您提供的任何帮助。我束手无策,无法弄清楚我做错了什么。我已经为此工作了几天,现在在一堵砖墙上。似乎应该很简单,但事实并非如此:-(

<body>
<?php
$name = $_POST['Name:'];
$email = $_POST['E-mail:'];
$phone = $_POST['Phone:'];
$message = $_POST['Message:'];

//Sending Email to form owner
$header = "From: $email_to\n";
$header .= "Reply-To: $email\n";
$subject = "Submission From My Form";
$email_to = "your@email.us";
$message = "Name: $name\n"."E-mail: $email\n"."Phone: $phone\n"."Message: $message\n";
mail($email_to, $subject, $message, $header);

?>
<h1>Thank You for Your Submission</h1>

<p> Your information has been sent.</p>

</article>
        <article class="grid_8 omega last-col">
          <div class="pad_box2">
            <h2 class="ind3">Get in Touch</h2>
             <form method="post" id="contact-form" action="Contacts.php">
                <div class="success">Contact form submitted!<br>
                    <strong>We will be in touch soon.</strong>
                </div>
                <fieldset>
                  <label class="name">
                    <input type="text" value="Name:">
                      <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span>
                  </label>
                  <label class="email">
                    <input type="text" value="E-mail:">
                      <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span>
                  </label>
                  <label class="phone">
                    <input type="text" value="Phone:">
                      <span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span>
                  </label>
                  <label class="message">
                    <textarea>Message:</textarea>
                      <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
                  </label>
                  <div class="buttons2">
                      <a href="#" data-type="reset" class="link1">Clear</a>
                      <a href="#" data-type="submit" class="link1">Submit</a>
                  </div>
                </fieldset>
              </form>
          </div>
        </article>
4

1 回答 1

1

您有多种方式的错误:

首先,所有行都$name = $_POST['Email:'];应该是例如:

$email = isset($_POST['email']) ? $_POST['email'] : '';

然后,您将创建相应的表单字段,如下所示:

Email: <input type="text" name="email" value="<?php echo htmlspecialchars($email);?>">

然后,电子邮件发送本身必须被一些 POST 和错误检查所包围。你的错误输出*This is not a valid name.总是在那里,等等......

老实说,看起来你应该从更基本的东西开始——无意冒犯!这里的任何人都无法帮助您,因为您需要的是一个好的教程。网上有很多这样的教程,可以帮助你在学习几天后掌握你的问题:)

于 2013-03-16T18:46:35.443 回答