优惠券应仅针对尚未查看该类型的 IP 显示。如果他们这样做,它应该回显错误页面。只允许用户查看页面一次。
IP 正在进入数据库,但当在该类型的数据库中找到 IP 时,PHP 无法正常工作以显示错误页面。
网址:http ://muhs.trinix.co/coupon?type=czo0OiJNZW93Ijs=
<?PHP
if(empty($_GET['type'])){die();}
mysql_connect("localhost", "muhs_cp", "********************");
mysql_select_db("muhs_cp");
$type = mysql_real_escape_string(unserialize(base64_decode($_GET['type'])));
$randid = rand(1, 9999999999);
$ip = $_SERVER['REMOTE_ADDR'];
$resultz = mysql_query("SELECT ip FROM coupons WHERE type = '$type' AND ip = '$ip' LIMIT 1");
if(mysql_fetch_array($resultz) !== false){
mysql_query("INSERT INTO `coupons` (`id`, `type`, `ip`) VALUES ('$randid', '$type', '$ip')");
$result = mysql_query("SELECT * FROM coupons WHERE type = '".mysql_real_escape_string($type)."'") or die(mysql_error());
$row = mysql_fetch_array( $result );
$expired = $row['expired'];
$notes = $row['notes'];
$cookie = $row['cookie'];
mysql_query("UPDATE `totals` SET `number` = `number` + 1 WHERE `type` = '".mysql_real_escape_string($type)."'");
}
else{
echo "
<html>
<head>
<title>Your Coupon</title>
<link href='css/screen.css' rel='stylesheet' type='text/css' />
</head>
<body id='wrapper'>
<div id='login'>
<h1>Whoops! Looks like this coupon has already been used.</h1>
<br />
<img src='../images/logo.png' />
<br />
<p>You are unable to make a coupon more than once.</p>
</div>
</body>
</html>"; die();};
?>
更新:我有一个额外的!在 if 语句中。我还能够更改代码,使其只允许用户查看该页面一次。