我有一个用html css和php创建的联系表单,但没有发送电子邮件。
目标:使用HTML和PHP创建工作联系表单
问题:电子邮件在提交时从未到达,我从未进入最终的email_success.php页面。它只带我到名为thankyou.php的空白页
我的代码基于我最近关于stackoverflow的问题(参见链接) contact form我在上传到我的网络主机服务器时解决了这个问题。
我的代码如下 - >
contact.php:
<!DOCTYPE HTML>
<html lang="sv">
<head>
<meta charset="UTF-8">
<!-- Iphone delete blue link styling -->
<meta name="format-detection" content="telephone=no">
<link rel="shortcut icon" href="_images/favicon.png" type="image/png">
<title>Contact</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="_css/main.css" rel="stylesheet" media="screen, projection">
</head>
<body>
<!-- Contact Form -->
<div id="form_Holder_Contact_dk">
<div id="form_Box_Contact_dk">
<form action="thankyou.php" method="post" name="contact_form">
<!-- L E F T C O L U M N -->
<div id="columnLeft_Contact_dk">
<!-- Name field -->
<input type="text" name="name" placeholder="NAME">
<!-- E-mail field -->
<input type="text" name="email" placeholder="E-MAIL">
<!-- Subject field -->
<input type="text" name="subject" placeholder="SUBJECT">
</div>
<!-- R I G H T C O L U M N -->
<div id="columnRight_Contact_dk">
<!-- Message field -->
<textarea name="message" placeholder="LEAVE A MESSAGE"> </textarea>
<!-- Send button -->
<input type="submit" value="SEND" name="submit" placeholder="SEND">
</div>
</form>
</div>
</div>
</body>
</html>
thankyou.php:
<?
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$email_message = "
Name: ".$name."
Email: ".$email."
Subject: ".$subject."
Message ".$message."
";
mail("my@emailexample.com" , "New inquiry" , $email_message);
header("Location: email_success.php");
?>
email_success.php:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Email Sent</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Email sent</h1>
</body>
</html>
错误可能是未连接位于两个不同列中的输入和textarea的提交按钮吗?我确实为名为contact_form的表单创建了一个名称,该名称未被使用。
非常感谢您的帮助,谢谢!