|
|
|
form ส่ง Email ไม่ได้ ขึ้น HTTP ERROR 500 อยากทราบวิธ๊แก้ไขครับ |
|
|
|
|
|
|
|
ผมลองเขียนตามนี้แต่ไม่สามารถส่งข้อความจากฟอร์มเข้าอีเมล์ได้ครับ ถึงแม้จะลบ recaptcha ออก แต่ก็ไม่สามารถส่งได้ครับ
index.html
<script src='https://www.google.com/recaptcha/api.js'></script>
<form id="contact-form" method="post" action="mail-contact-design.php" role="form">
<div class="form-group">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="hotelsystemenquiry" value="hotelsystemenquiry">
<label class="form-check-label" for="hotelsystemenquiry">Hotel System Enquiry</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="webdesignenquiry" value="webdesignenquiry">
<label class="form-check-label" for="webdesignenquiry">Website Design Enquiry</label>
</div>
<br>
<div class="form-group">
<br><label for="name">Name</label>
<input type="name" class="form-control" id="name" placeholder="Name">
</div>
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="email" aria-describedby="emailHelp" placeholder="Enter email">
<small id="email" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="Website">Website</label>
<input type="Website" class="form-control" id="website" placeholder="">
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="phone" class="form-control" id="phone" placeholder="">
</div>
<div class="form-group">
<label for="message">Comments</label>
<input type="message" class="form-control" id="message" rows = "3">
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="optin" id="optin" checked>
<label class="form-check-label" for="optin">
<small>Opt in for future offers</small>
</label>
</div>
</div>
<div class="form-group">
<div class="g-recaptcha" data-sitekey="6Lf5DR4UAAAAABfnuo5l1EhGAhsiLqXRa_R4Vveq"
data-callback="verifyRecaptchaCallback"
data-expired-callback="expiredRecaptchaCallback"></div>
</div>
<br>
<input type="submit" class="btn btn-success btn-send" value="Send message">
</form>
Code (PHP)
<?
require_once 'recapcha-php/recapchalib.php';
$privatekey = "6Lf5DR4UAAAAACArH2pC8uW4BRSUjBILYQnz_u9f";
$resp = recapcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_fleld"], $_POST["recaptcha_response_fleld"]);
if (!$resp->is_valid) {
die("ERROR : reCap Wrong");
} else {
$to_send = '[email protected]';
$email = $_POST['email'];
$website = $_POST['website'];
$phone = $_POST['phone'];
$message = $_POST['message'];
}
if ($_POST['hotelsystemenquiry']) {
$hotel = "Website Design Enquiry";
};
if ($_POST['webdesignenquiry']) {
$webdesign = "Hotel System Enquiry";
}
if ($_POST['optin']) {
$optins = "Opt in for future offers";
}
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=UTF-8\r\n";
$header.="From: ".$email;
if (mail($to_send, $email, $website, $phone, $messages_send, $hotelsystemenquiry,
$webdesignenquiry, $optin, $header)) {
echo "<h2>send complete</h2>";
} else {
echo "<h2> send fail</h2>";
}
?>
Tag : PHP, HTML, HTML5, JavaScript
|
ประวัติการแก้ไข 2018-06-05 17:13:47 2018-06-05 17:14:41
|
|
|
|
|
Date :
2018-06-05 17:12:51 |
By :
bakerylove |
View :
654 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปิดแสดง error แล้วเอา error มาดู
|
|
|
|
|
Date :
2018-06-06 07:16:23 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|