提前感谢您提供的任何帮助。我在斗智斗勇,不知道我做错了什么。我已经在这个工作了几天,现在在砖墙上。似乎它应该很简单,但它不是: - (
<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>
答案 0 :(得分: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.
这样的错误输出始终存在,依此类推......
老实说,看起来你应该从更基本的东西开始 - 没有冒犯!这里没有人可以帮助你,因为你需要的是一个很好的教程。网上有很多这样的教程可以帮助你在几天的学习后掌握你的问题:)