PHP 5.6.16不读取$ _post数据

时间:2016-01-17 20:53:34

标签: php post

我在两个服务器上使用这个确切的版本 - 一个完美无缺(旧PHP),而且这个版本不会读取$_POST元素的checkbox数据。

表格:

<form method=post action=fish.php?livewell=1&processrelease=1 enctype="multipart/form-data">Array ( )
    <table border=1 width=800>
        <tr>
            <td></td>
            <td>
                <CENTER>Fish</td>
            <td>
                <CENTER>Value</td>
            <tD>
                <CENTER>Release</td>
            <td>
                <CENTER>League</td>
        </tr>
        <tr>
            <td>
                <CENTER>
                    <IMG SRC=pics/fish/brook_trout.jpg width=45 title="Brook Trout">
            </td>
            <td>
                <FONT COLOR=green>Brook Trout</font> (
                <A HREF=fish.php?guide=1><FONT COLOR=#666666>Regular</font></A>)(
                <B>Fish level 9</B>)
                <BR>
                <FONT COLOR=blue><B>10 inches</B></font>-
                <FONT COLOR=purple><B>1 cm</B></font>-
                <FONT COLOR=green><B>3.24 mm</B></font>[
                <FONT COLOR=brown><B>1.065 lbs</B></font>]
                <BR>
            </td>
            <td>
                <CENTER>
                    <FONT COLOR=green>$0.90</font>
                    <BR>
            </td>
            <td>
                <CENTER>
                    <input type="checkbox" value="55" name="lwid[]">
            </td>
            <td>
                <CENTER>
                    <IMG SRC=bigbertha.gif height=22> This defeats your previous league record for
                    <FONT COLOR=green>Brook Trout</font> of lbs.
                    <BR>
            </td>
        </tr>
    </table>
    <BR>Running total right now is
    <FONT COLOR=green>$0.9</font>
    <BR>
    <BR>
    <input type=submit value="Release Checked Fish">
</form>

但是当我收到帖子时 - $lw[]内的所有数据都是空白的。

发布接收代码如下:

$box = $_POST['lwid'];
while (list($key, $val) = @each($lwid)) {
    $livewellsel = mysql_query("select * from tblFishCapture where id='$val' and playerId=$stat[id] limit 1");
    $lwnum = mysql_num_rows($livewellsel);
    if ($lwnum > 0) {
        $lw = mysql_fetch_array($livewellsel);
        $tfishsel = mysql_query("select name from tblFishTemplates where id='$lw[fishId]' limit 1");
        $tfish = mysql_fetch_array($tfishsel);
        $label = check_fish_bonus($lw[fishId], $lw[fishSize], 1);
        $fbonus = check_fish_bonus($lw[fishId], $lw[fishSize], 0);
        $level = get_fish_level($fbonus);
        $myval = check_fish_bonus($lw[fishId], $lw[fishSize], 3);
        $pn = get_place_name($body[id]);
        $ttText = translate_text_googleapi("You release", $languageCode[languageCode]);
        $tfish[name] = translate_text_googleapi("$tfish[name]", $languageCode[languageCode]);
        $label = translate_text_googleapi("$label", $languageCode[languageCode]);
        $ttFishlevel = translate_text_googleapi("Fish level", $languageCode[languageCode]);
        $ttBIW = translate_text_googleapi("back into <FONT COLOR=blue>the water</font>", $languageCode[languageCode]);
        print "$ttText <FONT COLOR=green>$tfish[name]</font> ($label)(<B>$ttFishlevel $level</B>) $ttBIW.<BR>";
        mysql_query("delete from tblFishCapture where playerId=$stat[id] and id='$val' limit 1");
    }
}

当我print_r($_post)时,它会读取 Array ( [lwid] => )

我正在使用这种解决方法,使我的编程与新PHP兼容:

if (!isset($PXM_REG_GLOB)) {

    $PXM_REG_GLOB = 1;

    if (!ini_get('register_globals')) {
        foreach(array_merge($_GET, $_POST) as $key => $val) {
            global $$key;
            $$key = (get_magic_quotes_gpc()) ? $val : addslashes($val);
        }
    }
    if (!get_magic_quotes_gpc()) {
        foreach($_POST as $key => $val) $_POST[$key] = addslashes($val);
        foreach($_GET as $key => $val) $_GET[$key] = addslashes($val);
    }
}

感谢任何帮助。

配置中是否缺少某些内容或与新PHP不兼容的内容?

编辑:

使用

Using "$_POST['lwid'];
     foreach($_POST['lwid'] as $val) {
// do something
}

仍然返回空结果。

2 个答案:

答案 0 :(得分:0)

请参阅official php website

上有关register_globals的说明
  

自PHP 5.3.0开始,此功能已被弃用,自PHP起已被删除   5.4.0。

只需使用$_POST['lwid']代替$lwid

答案 1 :(得分:0)

我最终自己修理了它。

将复选框更改为

<input type=\"checkbox\" value=\"$lw[id]\" name=\"$lw[id]\">

阅读以下复选框:

foreach ($_POST as &$val) {
//do something
}