以下是希望有人可以帮助我的代码
Contact.php
<?php
@error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
@ini_set('display_errors', true);
@ini_set('html_errors', true);
@ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_WARNING);
ini_set("log_errors", 1);
ini_set("error_log", "php-error.log");
error_log( "Hello, errors!" );
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@arjen079.com";
$email_subject = "Contact Application Website!";
$email_noreply = "noreply@arjen079.com";
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$subject = $_POST['subject']; // required
$message = $_POST['message']; // required
$email_message = "Form Details Below:\n\n";
$email_messagesender = "Here is a copy of the form you filled in:\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Subject: ".clean_string($subject)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
$email_messagesender .= "First Name: ".clean_string($name)."\n";
$email_messagesender .= "Email: ".clean_string($email)."\n";
$email_messagesender .= "Subject: ".clean_string($subject)."\n";
$email_messagesender .= "Message: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
// send a copy to sender
$headers = 'From: '.$email_noreply."\r\n".
'Reply-To: '.$email_noreply."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, "Thanks For contacting!", "Thanks for contacting me, I will reply to you shortly. \n\n----------------\n\n" . $email_messagesender, $headers);
echo 'Message Succesfully Sent!<script>$(\'response-message\').text(\'Message Succesfully Sent!\');var form = document.getElementById("contact-form");form.reset();</script>';
}
?>
联系表格:
<div class="container">
<div class="row">
<div class="span7">
<form action="http://www.arjen079.com/contact.php" method="post" class="contact-form" id="contact-form">
<h1>Contact</h1>
<hr class="fancy-hr">
<input type="text" name="name" placeholder="Name" class="required">
<input type="email" name="email" placeholder="Email" class="required">
<input type="text" name="subject" placeholder="Subject" class="required">
<textarea name="message" placeholder="Message" class="required"></textarea>
<div class="response-message"></div>
<input type="submit" value="Submit" name="submit" class="float-right">
<div class="clear"></div>
</form>
谢谢! ;)
答案 0 :(得分:0)
echo 'Message Succesfully Sent!<script>$(\'response-message\').text(\'Message Succesfully Sent!\');var form = document.getElementById("contact-form");form.reset();</script>';
错误在这部分。
$(\'response-message\')
应为$(\'.response-message\')
。
注意你遗失的.
?你试图将ELEMENT称为响应消息,而不是具有类的div。