我正在尝试制作一个小型浏览器游戏,但我无法从URL中获取$ _GET []值的值。任何人都可以确认我做的是正确的事情,或者只是全力以赴PHP的东西?
// General settings
$site = "http://localhost/index.php";
$buildfood0 = "dSDF3HJKhbv432dsfs";
// Food forms
$form_food0 = "<img src='./images/game/b7_.png' /><a class='button' href='$site?code=$buildfood0'>Build</a>";
if($lvl_food == 0){
if($_GET['code']) {
$codefood = $_GET['code'];
if($codefood0 == $buildfood0){
require("./connect.php");
mysql_query("UPDATE users SET lvl_farm='1' WHERE username='$username'");
mysql_close();
}
else
null;
}
}
else if($lvl_food == 1){
echo "<img src='./images/game/b7.png' />";
}
答案 0 :(得分:1)
变化:
if($lvl_food == 0){
if($_GET['code']) {
$codefood = $_GET['code'];
if($codefood0 == $buildfood0){
------------------------^ // Wrong. Remove the 0
将其设为:
if($lvl_food == 0){
if($_GET['code']) {
$codefood = $_GET['code'];
if($codefood == $buildfood0){