我被困住了,我希望有人能帮助我。我正在尝试使用 PHP action="" method="post" 向我的网站添加一个简单的联系表单。当我单击“提交”按钮时,不是运行脚本,而是打开“send_contact.php”页面,您会看到所有代码。我已经检查并测试了我的服务器(blue.host),它被设置为运行 php 脚本。我已经尝试了一切,我很茫然。这是HTML:
<div class="form">
<form id="myform" name="myform" action="send_contact.php" method="post">
<label>Name</label>
<input type="text" name="name" id="name" />
<label>E-mail</label>
<input type="text" name="email" id="email" />
<label>Phone</label>
<input type="text" name="phone" id="phone" />
<label>Message</label>
<textarea name="message" rows="5" cols="60"></textarea>
<button name="send" type="submit">send</button>
<button name="reset" type="reset">reset</button>
<div class="spacer"></div>
</form><!--end myform div-->
</div><!--end form div-->
这是 PHP 脚本:
<?php
// From
$header="from: $name <$mail_from>";
// Mail of sender
$mail_from="$customer_mail";
// Contact phone
$phone ="$phone";
// Details
$message="$message";
// Enter your email address
$to ='jacine.arias@gmail.com';
$send_contact=mail($to,$header,$mail,$phone,$message);
// Check, if message sent to your email
// display message "Thank you! Your message has been recieved."
if($send_contact){
echo "Thank you! Your message has been recieved.";
}
else {
echo "ERROR";
}
?>
这是CSS:
/*-----------FORM---------------*/
.form {
border: 1px solid #262223;
margin: 0 auto;
padding: 14px;
width: 375px;
}
.form label {
display: block;
text-align: right;
width: 80px;
float: left;
}
.form input {
float: left;
font-size: 12px;
padding: 4px 2px;
border: 1px solid #262223;
width: 270px;
margin: 2px 0 10px 10px;
}
textarea {
float: left;
font-size: 12px;
padding: 4px 2px;
border: 1px solid #262223;
width: 270px;
margin: 2px 0 20px 10px;
}
button[type="submit"] {
clear: both;
color: #fff;
width: 100px;
height: 31px;
text-align: center;
background: #F20F4B;
margin-right: 5px;
float: left;
}
button[type="reset"] {
clear: both;
color: #fff;
width: 100px;
height: 31px;
text-align: center;
background: #F20F4B;
display: inline;
}
这是我网站上的实际页面:http: //jacineariasdesign.jacineariasweb.com/contact.html 任何帮助完成这项工作将不胜感激!谢谢!