문의 양식과 제품 양식이 있습니다. 제품 유형에만 제품 가치가 있는지 확인하고 싶지만 조건부를 통과 할 수 있습니다.
깨진 코드
// If visitor filled out the form on the "Contact Us" page (/contact/index.php) then no 'product' field is required.
if ($_SERVER['HTTP_REFERER'] != "http://www.url.com/contact/index.php" || "http://url.com/contact/index.php") {
if(strlen($product) < 2) {
$errors[] = "<font color='red'>Please enter the product requesting.</font>";
}
}
문제 해결/디버깅 코드
$serverValue = $_SERVER['HTTP_REFERER'];
print "The value of SERVER is ". $serverValue;
echo "<br />";
print $_SERVER['DOCUMENT_ROOT']."/contact/index.php";
echo "<br />";
if ($_SERVER['HTTP_REFERER'] != "http://www.url.com/contact/index.php" || "http://url.com/contact/index.php" || "/home/url/public_html/contact/index.php") {
//if ($_SERVER['HTTP_REFERER'] != $_SERVER['DOCUMENT_ROOT']."/contact/index.php") {
print "This is NOT the Contact page";
} else {
print "This IS the Contact page";
}
문제 해결/디버깅 출력
서버의 값은 http://url.com/contact/index.php입니다/home/url/public_html/contact/index.php 이는 연락처 페이지
당신은 올바른 HTTP_REFERER가 전달되는하지만 그냥 제대로 평가하지 않습니다 출력에 의해 볼 수 있습니다 아닙니다. 거기에 내가 다른 것들을 시도하고있는 주석 처리 된 라인이 있습니다. 나에게 쉽게 가보 라. PHP에 새로 온 것.
좋아, 나는 내가 잘못하고 있었는지 이해없이 성공
if ($_SERVER['HTTP_REFERER'] != "http://www.url.com/contact/index.php" || $_SERVER['HTTP_REFERER'] != "http://url.com/contact/index.php") {
if(strlen($product) < 2) {
$errors[] = "<font color='red'>Please enter the product requesting.</font>";
}
}
다른 생각으로이 시도?
이 작업을 수행하면 –