0
我一直試圖讓這個工作一段時間,我已經嘗試了大量的事情來嘗試和解決這個問題,但我可能只是讓事情變得更糟。我遇到的問題是,當我提交我的聯繫表單時,它不會發送郵件,它只是將我重定向到「index.html#」PHP/CSS郵件發送到index.html#
我已在下面發佈了我的網站的代碼。請讓我知道如果你們能看到我想念的任何東西。
HEAD HTML
<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
// SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
$("#form1").validationEngine({
ajaxSubmit: true,
ajaxSubmitFile: "ajaxSubmit.php",
ajaxSubmitMessage: "Thank you, We will contact you soon !",
success : false,
failure : function() {}
})
});
</script>
BODY HTML(index.html的)
<div id="contact">
<h3>need more info?</h3>
<form action="#" method="post">
<fieldset>
<p>
<label for="name">Name:</label>
</p>
<p>
<input type="text" id="name" placeholder="Enter your full name" />
<label for="email">Email:</label>
</p>
<p>
<input type="email" id="email" placeholder="Enter your email address" />
<label for="message">Message:</label>
</p>
<p>
<textarea id="message" placeholder="Looking for a quote?"></textarea>
<input type="submit" value="Send message" />
</p>
</fieldset>
</form>
<?php
$ToEmail = '[email protected]';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
</div>
CSS(contact.css)
body, div, h3, form, fieldset, input, textarea {
margin: 0; padding: 0; border: 0; outline: none;
}
html {
height: 100%;
}
#contact {
float:right;
width: 250px; margin: 60px auto; padding: 60px 30px;
background: #9fad23; border: 1px solid #e1e1e1;
-moz-box-shadow: 0px 0px 8px #444;
-webkit-box-shadow: 0px 0px 8px #444;
-webkit-border-top-left-radius: 25px;
-webkit-border-bottom-left-radius: 25px;
-moz-border-radius-topleft: 25px;
-moz-border-radius-bottomleft: 25px;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
}
h3 {
font-size: 25px; color: #445668; text-transform: uppercase;
text-align: center; margin: 0 0 25px 0;
}
label {
float: left; clear: left; margin: 11px 20px 0 0; width: 95px;
font-size: 12px; color: #445668;
text-transform: uppercase;
}
input {
width: 200px;
height: 35px;
background: #5E768D;
background: -moz-linear-gradient(top, #546A7F 0%, #5E768D 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#546A7F), color-stop(20%,#5E768D)); /* webkit */
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 0px 1px 0px #f2f2f2;
-webkit-box-shadow: 0px 1px 0px #f2f2f2;
font-family: sans-serif;
font-size: 12px;
color: #f2f2f2;
text-transform: uppercase;
margin-top: 0;
margin-right: 0;
margin-bottom: 20px;
margin-left: 0;
padding-top: 5px;
padding-right: 20px;
padding-bottom: 0px;
padding-left: 20px;
}
input::-webkit-input-placeholder {
color: #a1b2c3;
}
input:-moz-placeholder {
color: #a1b2c3;
}
textarea {
width: 200px; height: 170px; padding: 12px 20px 0px 20px; margin: 0 0 20px 0;
background: #5E768D;
background: -moz-linear-gradient(top, #546A7F 0%, #5E768D 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#546A7F), color-stop(20%,#5E768D)); /* webkit */
border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
-moz-box-shadow: 0px 1px 0px #f2f2f2;-webkit-box-shadow: 0px 1px 0px #f2f2f2;
font-family: sans-serif; font-size: 12px; color: #f2f2f2; text-transform: uppercase;
}
textarea::-webkit-input-placeholder {
color: #a1b2c3;
}
textarea:-moz-placeholder {
color: #a1b2c3;
}
input:focus, textarea:focus {
background: #728eaa;
background: -moz-linear-gradient(top, #668099 0%, #728eaa 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#668099), color-stop(20%,#728eaa)); /* webkit */
}
input[type=submit] {
width: 150px; height: 40px; float:right; padding: 10px 15px; margin: 0 15px 0 0;
-moz-box-shadow: 0px 0px 5px #999;-webkit-box-shadow: 0px 0px 5px #999;
border: 1px solid #556f8c;
background: -moz-linear-gradient(top, #718DA9 0%, #415D79 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#718DA9), color-stop(100%,#415D79)); /* webkit */
cursor: pointer;
}
AjaxSubmit.php
<?php
$name = $_POST['name']; // contain name of person
$email = $_POST['email']; // Email address of sender
$web = $_POST['web']; // Your website URL
$body = $_POST['text']; // Your message
$receiver = "[email protected]" ; // hardcorde your email address here - This is the email address that all your feedbacks will be sent to
if (!empty($name) & !empty($email) && !empty($body)) {
$body = "Name:{$name}\n\nWebsite :{$web}\n\nComments:{$body}";
$send = mail($receiver, 'Contact Form Submission', $body, "From: {$email}");
if ($send) {
echo 'true'; //if everything is ok,always return true , else ajax submission won't work
}
}
?>
,能得到任何PHP錯誤?你有開啓PHP錯誤嗎? – Sean
[不要將'$ _POST'變量直接傳遞到郵件標題中,它會讓腳本*變得很寬*](http://www.securephpwiki.com/index.php/Email_Injection) – Dunhamzzz