저는 PHP에 익숙해 져서 불쌍한 지식을 변명하지만 사용자가 내 웹 페이지에 등록 할 때 전자 메일 양식을 사용하고 있지만 오류가 발생합니다. 나는 그것을 교체를 인터넷 검색 후eregi를 preg_match로 대체하면 오류가 발생합니다.
$error_message = "";
$email_exp = "^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "New e-mail subscriber";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if
(!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the email your submitted.');
}
$email_from = $_POST['email']; // required
$error_message = "";
$email_exp = "/^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$/";
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Email: ".clean_string($email_from)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?
}
?>
먼저 나는 때문에 다음과 같이이었다 초기 스크립트의 오류 "eregi는 감가 상각"했다 :
전체 스크립트는 다음과 같다 다음을 포함합니다 :
$error_message = "";
$email_exp = "/^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$/";
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
그러나 이제 이메일 주소는 다음과 같습니다. 올바른 :
죄송합니다. 이 제출 된 양식에 오류가있었습니다. 이러한 오류는 아래에 나와 있습니다.
입력하신 이메일 주소가 유효하지 않습니다.
돌아가서 이러한 오류를 수정하십시오.
도움이 많이
조언 : 웹에서 둘 이상의 (전자 메일) 양식을 찾아서 테스트하십시오. 하나는 실패없이 일할 의무가있다. 문자 그대로 이미 수천 가지가 있습니다. 이미 많은 보안 기능과 유효성 검사 기능이 내장되어 있습니다. 너 자신에게만 국한하지 마라. 건배! –