我試圖將下拉菜單連接到我的聯繫頁面時似乎無法找到我的錯誤。我跟蹤了我的錯誤日誌,但是由於我對電子郵件不太熟悉,因此我的配置混亂了,請提前感謝您的任何建議。如何將下拉菜單連接到電子郵件 - php
<?php
/***************** Configuration *****************/
// Enter your email, where you want to receive the messages.
$contact_email_to = "EMAIL NAME";
// Subject prefix
$contact_subject_prefix = " ";
// Name too short error text
$contact_error_name = "Name is too short or empty!";
// Email invalid error text
$contact_error_email = "Please enter a valid email!";
// Subject too short error text
$contact_error_subject = "Subject is too short or empty!";
// Message too short error text
$contact_error_message = "Too short message! Please enter something.";
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
// The Request must be Ajax POST, enter a message for direct access requests.
die('Invalid Request!');
}
if(isset($_POST)) {
$name = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
$email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
$company = filter_var($_POST["company"], FILTER_SANITIZE_STRING);
$message = filter_var($_POST["message"], FILTER_SANITIZE_STRING);
$subject = ($_GET["subject"]);
if(strlen($name)<4){
die($contact_error_name);
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
die($contact_error_email);
}
if(strlen($company)<3){
die($contact_error_subject);
}
if(strlen($message)<3){
die($contact_error_message);
}
$sendemail = mail($contact_email_to, $company, $subject, $message,
"From: ".$name." <".$email.">" . PHP_EOL
."Reply-To: ".$email . PHP_EOL
."X-Mailer: PHP/" . phpversion()
);
if($sendemail) {
echo 'OK';
} else {
echo 'Could not send mail! Please check your PHP mail configuration.';
}
}
?>
<div class="row contact-wrap">
<div class="status alert alert-success" style="display: none"></div>
<div class="col-md-8">
<div id="sendmessage">Your message has been sent. Thank you!</div>
<div id="errormessage"></div>
<form action="" method="post" role="form" class="contactForm">
<div class="form-group">
<input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
<div class="validation"></div>
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
<div class="validation"></div>
</div>
<div class="form-group">
<input type="text" class="form-control" name="company" id="company" placeholder="Your Company" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
<div class="validation"></div>
</div>
<div class="form-group">
<select name="subject" class="form-control" name="subject" id="subject">
<option value="">---</option>
<option value="sales">Sales</option>
<option value="safety">Safety</option>
<option value="accountsP">Accounts Payable</option>
<option value="accountsR">Accounts Receivable</option>
<option value="accountsR">Human Resources</option>
<option value="accountsR">Operations</option>
<option value="accountsR">Equipment</option>
<option value="accountsR">Management</option>
</select>
</div>
<div class="form-group">
<textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea>
<div class="validation"></div>
</div>
<div class="text-center"><button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button></div>
</form>
</div>
什麼是錯誤 – Rahul