我有一个包含3个字段的简单表单,contact_name contact_email& contact_message当我提交时,输入表格的数据不会通过电子邮件发送给我。但是,如果我检查发布的是什么,我可以看到一个数组被发布:
阵 ( [contact_name] =>保罗 [contact_email] => test@test.com [contact_message] => d; LKF'DSKF; LSDKF )
这是我的表单代码:
<form role="form" name="form1" action="send_form_email.php" method="post">
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="name">Name</label>
<input class="form-control" type="text" name="contact_name" placeholder="Name" id="contact_name">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="email">Email Address</label>
<input class="form-control" type="email" name="contact_email" placeholder="Email Address" id="contact_email">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="message">Message</label>
<textarea name="contact_message" placeholder="Message" class="form-control" rows="5" id="contact_message"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="form-group col-xs-12">
<button type="submit" class="btn btn-lg btn-success">Send</button>
</div>
</div>
</form>
这是php脚本:
<?php
// Contact subject
$subject ='Message from Leeds Computers';
// Details
$message="$contact_message";
// Mail of sender
$mail_from="$contact_email";
// From
$header="from: $contact_name <$mail_from>";
// Enter your email address
$to ='test@gmail.com';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've received your contact information";
}
else {
echo "ERROR";
}
?>
<? echo '<pre>';
print_r($_POST);
echo '</pre>';
?>
非常感谢任何帮助
答案 0 :(得分:0)
您可能需要修改它以查看POST:
// Details
$message=$_POST["contact_message"];
// Mail of sender
$mail_from=$_POST["contact_email"];
// From
$header="from: " . $_POST["contact_name"] . " <$mail_from>";