-2

我正在尝试制作一个小型浏览器游戏,但我无法从 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' />";
    }
4

1 回答 1

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){
于 2013-03-02T17:49:07.853 回答