문의 양식이 http://www.kaimeramedia.com/derek/Website/contact.php입니다. PHPcodechecker.com에서 PHP 코드를 확인했는데 구문 오류가 없다고합니다. 나는 제출 코드를 누를 때마다 다음 제출처로 넘어 가기 때문에 시작 코드가 일부 매너에서 작동하고 있다고 생각합니다 : "부적절한 이메일 주소가 발견되었습니다. 브라우저의 뒤로 버튼을 누르고 다시 시도하십시오".PHP 문의 양식 유효성 검사가 작동하지 않습니다.
나는 전자 메일 유효성 검사가 통과되고 메시지를 제출할 수 있도록 코드를 다르게 작성해야하는지 알고 싶습니다. 거꾸로 코딩 된 것이 있는지 확실하지 않습니다. 나는 많은 조합을 시도했다. 그러나 그것이 가장 멀리 있기 때문에 나는 mailform.php 오류없이왔다.
<?php
session_start();
$dontsendemail = 0;
$possiblespam = FALSE;
$strlenmessage = "";
$email = $_REQUEST['email'];
$name = $_REQUEST['name'];
$message = $_REQUEST['message'];
$subject = "Regarding Your Portfolio";$emailaddress = "[email protected]";
// checks if name field is empty
function checkname() {
if (empty($name)) {
die ("You did not enter your name. Please hit your browser back button and try again.");
return 1;
}
}
// checks if the captcha is input correctly
function checkcaptcha() {
if ($_SESSION["pass"] != $_POST["userpass"]) {
die("Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again.");
return 1;
}
}
// checks proper syntax
function checkemail() {
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email));
else{
die("Improper email address detected. Please hit your browser back button and try again.");
return 1;
}
}
function spamcheck($field) {
if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){
$possiblespam = TRUE;
}else $possiblespam = FALSE;
if ($possiblespam) {
die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
return 1;
}
}
function strlencheck($field,$minlength,$whichfieldresponse) {
if (strlen($field) < $minlength){
die($whichfieldresponse);
return 1;
}
}
if ($dontsendemail == 0) $dontsendemail = checkcaptcha($email);
if ($dontsendemail == 0) $dontsendemail = checkemail($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($name);
if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($name,3,"The Name field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $name,$email"); include "thankyou.php";}
?>
가이 코드에 가짜 이메일을 넣어,하지만 난 그게 될 것입니다 잘못된 곳 누구나 볼 수 있다면 진짜는 mailform.php 파일 에 다음 mailform.php 파일의 코드는 대단히 감사합니다.
시험용 이메일 주소를 업로드 할 수 있습니까? – MichaelH
@MichaelH는 그렇게 중요합니까? – giorgio
@giorgio 정규식 문제 일 수 있다고 생각했습니다. – MichaelH