이름, 전화 번호 및 선택적 설명 섹션이 필요한 등록 양식이 있습니다. 여러 테스트를 실행 한 후 폼이 제출되고 (PHP 코드의 맨 아래) 페이지가 "감사 페이지"로 리디렉션됩니다. 그러나 이메일을 전혀받지 못합니다. 누구든지 내가 뭘 잘못하고 있는지 알아?내 HTML 양식을 제출했지만 이메일을받지 못했습니다.
<form class="register-form" name="registerform" method="post" action="form-to-email.php">
<div class="form-column">
<p>Fields marked with * are required.</p>
<label for="first_name">First Name *</label>
<input type="text" id="first_name" name="first_name" placeholder="John">
<label for="last_name">Last Name *</label>
<input type="text" id="last_name" name="last_name" placeholder="Smith">
<label for="phone">Phone Number</label>
<input type="text" id="phone" name="phone" placeholder="503 999 9999">
<label for="comments">Comments</label>
<textarea id="comments" name="comments"></textarea>
</div><!--/ Form Column -->
<div class="submit-wrap"><input class="submit-form" type="submit" value="Register" /></div>
</form><!--/ Form -->
는 PHP는 다음과 같습니다 :
<?php
$myemail = '[email protected]';
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$visitor_phone = $_POST['phone'];
$comments = $_POST['comments'];
$to = $myemail;
$email_subject = "$first_name\n $last_name\n registered for Winter Camp 2015";
$email_body = "They said: \n $comments". "Their phone number is $visitor_phone.\n".
$headers = "From: $myemail\n";
mail($to,$email_subject,$email_body,$headers);
header('Location: registered-thanks.html');
>
서버는 어떻게 설정됩니까? 서버에 필요한 비트 (예 : MTA 등)가 설치되어 있고 메일을 릴레이 할 수 있습니까? – slugonamission
코드에 오류가 있습니다. '$ email_body ='는 세미콜론으로 끝나지 않습니다. – RST