【发布时间】:2018-12-10 22:50:58
【问题描述】:
我正在使用 bootstrap 4 构建一个站点,并添加了一个表单。我把它放在我的服务器上并运行它,它可以工作!有点。有4个字段,名字,姓氏,电子邮件,电话。验证有效,我已将其发送到电子邮件并且有效,但无论在网站的输入字段中输入什么,电子邮件都会返回:
Name: S S.
Email: S.
Phone: S.
这是我的 php:
<?php
$first_name= S_POST['first_name'];
$last_name= S_POST['last_name'];
$email= S_POST['email'];
$phone= S_POST['phone'];
$email_from =' Company, llc';
$email_subject = 'New Message From A Guest';
$email_body = "Name: $first_name $last_name.\n".
"Email: $email.\n".
"Phone: $phone.\n";
$to ="me@business.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("location: index.html");
?>
表单 HTML:
<form class="form inline d-flex justify-content-center" action="contact.php" method="POST" role="form">
<br style="clear:both">
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="control" id="first_name" name="first_name" placeholder="First Name" required>
</div>
<div class="form-group">
<input type="text" class="control" id="email" name="email" placeholder="Email" required>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="control" id="last_name" name="last_name" placeholder="Last Name" required>
</div>
<div class="form-group">
<input type="text" class="control" id="phone" name="phone" placeholder="Phone" required>
</div>
</div>
<div class="col-sm-12">
<button type="submit" id="submit" name="submit" class="btn btn-primary">SEND</button>
</form>
什么可能导致它只返回 S 作为这些输入的值?任何帮助将不胜感激
【问题讨论】:
-
您使用的是“S_”,但应该是美元 $_
标签: php html bootstrap-4