“提交”按钮将我发送到一个空白页面,我在那里获得mysite.com/mail.php,我不在本地主机上,所以一切都在站点上,所以我不确定为什么我继续看到php按下提交按钮时,下面的代码。这是我第一次使用php,并且还将网站上传到虚拟主机。任何帮助将不胜感激。
<!-- Form -->
<section>
<header class="major">
<h2>Request a Free onsite Consultation</h2>
</header>
<div class="row">
<div class="col-6 col-12-small">
<section class="box">
<form method="post" action="mail.php" >
<div class="row gtr-50 ">
<div class="col-5 col-12-small ">
<input name="name" placeholder="First and Last Name" type="text" />
</div>
<div class="col-5 col-12-small">
<input name="phone" placeholder="Phone Number" type="text" />
</div>
<div class="col-5 col-12-small">
<input name="email" placeholder="Email" type="text" />
</div>
<div class="col-5 col-12-small">
<input name="city" placeholder="City" type="text" />
</div>
<div class="col-12">
<textarea name="message"
placeholder="Let us know what you're looking to get."></textarea>
</div>
<div class="col-12">
<button class=" icon solid fa-envelope"
type="submit" >Send Message</button>
</div>
</div>
</form>
</section>
**My php code for how to handle the users info**
<?php
$myemail = "myemail@emailprovider.com";
$errors ="";
if(isset($_POST['submit'])){
$name = $_POST['name'];
$phone = $_POST['phone'];
$email_address = $_POST['email'];
$city = $_POST['city'];
$message = $_POST['message'];
if(empty($_POST['name']) || {
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['city']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
}
$to = $myemail;
$email_body = "You have received a new message from: $name \n ".
"From City: $city \n".
"Phone Number: - $phone \n".
"Their Email is: $email_address\n and Message: \n $message";
$headers = "Reply-To: $email_address";
mail($to,$email_body, $headers);
echo"Location: thankyou.html";
}
?>