【发布时间】:2017-11-15 19:44:42
【问题描述】:
我有一个联系表和一个产品表。我想检查以验证仅在产品表单上是否存在产品价值,但我可以获得通过的条件。
破解密码
// 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";
}
故障排除/调试输出
SERVER 的值为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>";
}
}
还有其他想法吗?
【问题讨论】:
-
这不可靠使用
标签: php http-referer