0

我正在尝试设置我的 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>
4

2 回答 2

0

究竟是什么不起作用或您需要帮助?请更具体。

话虽如此,我马上就看到了一些问题。

您的主要问题是该行无效,这可能导致整个脚本失败:

$recipient = "horgantm@gmail.com<script type="text/javascript"> ...

您必须转义双引号或改用单引号。(看看突出显示如何变化?)

您在这一行还有一个额外的括号:

<<form action="mail.php" method="POST">

为什么无论如何在收件人字段中嵌入了一个脚本?

编辑:我的答案发布后,OP 更改了代码。

于 2013-10-16T16:24:59.470 回答
0
于 2013-10-16T16:25:53.200 回答