소리)와에 메일 요청을 보냅니다 -
그럼, 질문은 전자 메일 서버.
쉽고 광범위하게 지원되므로 양식을 다시 유효화하고 요청을 전자 메일 서버로 보내는 서버에 PHP를 사용하는 것이 좋습니다.
는이 HTML
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="script.js"></script>
<form id="emailForm" method="post" action="mail.php">
<input type='text' name='firstName' id="firstName"><br>
<input type='text' name='lastName' id='lastname'><br>
<input type='submit' value='submit' name='submit'>
</form>
당신은 사용자가 자바 스크립트와 jQuery를 사용하여 모든 분야에서 무언가를 입력했는지 확인 할 수있는 말.
var formIsOkay = true;
$(document).ready(function() {
$('#emailForm').submit(function() {
$('#emailForm input').each(function() {
if (this.val() == '') { formIsOkay = false; }
}
return formIsOkay;
}
}
을 그리고 email.php로에서이 같은 것이다 : 말 파일 script.js에, 당신은
<?php
$to = '[email protected]';
$from = '[email protected]';
$subject = 'Form';
$message = 'Hello, the following variables were supplied:<br>';
foreach($_POST as $key => $val){
$message .= "$key = $val<br>";
}
$message = wordwrap($message, 70);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: $to" . "\r\n";
$headers .= "From: $from" . "\r\n";
mail($to, $subject, $message, $headers);
?>
당신은 PHP는이에 대한 서버에서 실행해야합니다, 그리고 PHP에서 SMTP 서버 설정,하지만 대부분의 서버 가이 있습니다. 참고 btw PHP가 지금 양식을 재정렬하지 못하는 방식으로 누군가가 빈 양식을 제출할 때 여전히 전자 메일로 전송됩니다.
클라이언트가 javascript를 요청했습니다. 그냥 배달하려고합니다. –