我正在尝试设置我的 PHP 联系表格,以便当您单击“发送”时它会说谢谢并将您重定向到主页。这是我的 php 和 html 脚本。我知道它只有几行需要调整,但不确定如何调整。我将 mail.php 文件上传到我的网站目录中。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$recipient = "horgantm@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
if(mail($recipient, $subject, $formcontent, $mailheader))
{
header("Location: http://www.darthvixcustomsabers.com/index.html");
exit;
}
else
{
die("Error!");
}
echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
<!doctype html>
<html>
<head>
<title> DV Custom Sabers </title>
<meta charset="utf-8">
<link type="text/css" rel="stylesheet" href="style/kotorsale.css" />
<meta name="viewport" content="width=device-width" />
</head>
<div class="header"><a href="index.html">Darthvix Custom Sabers</a></div>
<div class="header1">DV Custom Sabers is the place to go for your saber needs!</div>
<div class="logo"><a href="index.html"><img src="images/logo.png" alt="schedule" height="200" width="350" border="0"></a></div>
<ul id="nav">
<li><a href="index.html">Home</a></li>
<li><a href="aboutme.html">About Me</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="Gallery.html">Gallery</a></li>
<li><a href="kotorsale.html">For Sale</a></li>
<li><a href="buildlog.html">Build Log</a></li>
<li><a href="contact.html"> Contact Us</a></li>
</ul>
<div id="form">
<<form action="mail.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Priority</p>
<select name="priority" size="1">
<option value="Low">Low</option>
<option value="Normal">Normal</option>
<option value="High">High</option>
<option value="Emergency">Emergency</option>
</select>
<br />
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
</div>
</body>
</html>