我一直无法让我的php邮件脚本工作。我是相当新的,所以请和我在一起。
我的php邮件表单似乎只返回输入字段的标题,而不是输入的实际信息..
这是我现在的代码。任何帮助,将不胜感激。
<form id="contact_form" class="cf" role="form" name="contact_form" method="post" action="mailscript.php">
<div id="left_form_container">
<div class="half_left_cf">
<input type="text" name="name" id="input_name" placeholder="Name">
<input type="email" name="email" id="input_email" placeholder="Email address">
<input type="text" name="subject" id="input_subject" placeholder="Subject">
</div>
</div>
<div id="right_form_container">
<div class="half_right_cf">
<textarea name="message" id="input_message" type="text" placeholder="Message"></textarea>
<div id="submit_container">
<input type="submit" name="submit" value="Submit" id="input_submit">
</div>
</div>
</div>
</form>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "mail@website.com";
$body = "From: ".$name."\n E-Mail: ".$email."\n Message:\n" .$message;
if(empty($_POST['name'])){
$nameErr = "Name is required";}
if(empty($_POST['email'])){
$nameErr = "Email is required";}
if(empty($_POST['subject'])){
$nameErr = "Subject is required";}
if(mail ($to, $subject, $body)){
echo "<script>
alert('Thank you for sending your message!');
window.location.href='index.php'; </script";}
else {
echo "Mail was not sent!";}
?>
正如我所说,出于某种原因,它只是没有从框中返回任何输入,只有标题..
感谢您的帮助。