당신이 도울 수 있기를 바랍니다.구문 오류가 없지만 php 전자 메일 양식이 계속 실패합니다.
내 웹 사이트의 2 개 장소에서 구현 된 코드가 있습니다.
어떤 이유로 양식이 매번 전송되지 않습니다. 아래 코드는 구문 검사기를 통해 실행했으며 문제가되는 한 괜찮습니다.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$message = $_POST['message'];
$from = 'From: Roofing Solutions Contact Form';
$to = '[email protected]';
$subject = 'Question Sent From Website Form';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Number: $number\n Message:\n $message";
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>
그래서 나는 그것에 대해 당황하고 있습니다. 그리고 safetys를 위해서, 여기에 html 형식이 있습니다 :
<form method="post" action="contactform.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Contact Number</label>
<input name="number" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
감사합니다.
귀하의'$의 from' 무서운 보인다. – urzeit
-1 (http://stackoverflow.com/questions/23828423/php-form-doesnt-work?rq=1 –
)에서 헤더가 헤더에 있어야합니다. 이 페이지의 예제 2를 참조하십시오. http://php.net/manual/en/function.mail.php –