POST变量在服务器端无法识别

时间:2012-06-08 11:50:09

标签: php variables post server-side

我刚刚从共享托管转移到专用托管,突然POST无效。变量根据萤火虫发送

jquery....min.js (line 4)
HeadersPostResponseHTML
Parametersapplication/x-www-form-urlencoded
current_subtab_1    0
current_tab_1   0
delivery_options    Standard (5 working days)
new_copies  1500
p_binding   Portrait
p_colours_fs    Full Colour. (CMYK Process)
p_colours_fs_c  No Lamination
p_colours_t Full Colour. (CMYK Process)
p_copies    1000
p_cover Self Cover
p_cover_c   Silk
p_format    A4 (Portrait Only)
p_pages 8
p_paper 130 GSM, coated
p_paper_type    Silk
Source
current_tab_1=0&current_subtab_1=0&delivery_options=Standard+(5+working+days)&    p_copies=1000&p_paper=130+GSM%2C+coated&p_paper_type=Silk&p_colours_t=Full+Colour.+(CMYK+Process)&p_pages=8&p_binding=Portrait&p_format=A4+(Portrait+Only)&p_cover=Self+Cover

但是当我打开服务器端的错误报告时,它表示所有变量都是未定义的。是的,他们是正确定义的,脚本工作正常......

<br />
<b>Notice</b>:  Undefined index:  current_tab_1 in <b>calculate.php</b> on line     <b>6</b><br />
<br />
<b>Notice</b>:  Undefined index:  current_tab_1 in <b>calculate.php</b> on line     <b>215</b><br />
<br />
<b>Notice</b>:  Undefined index:  current_subtab_1 in <b>calculate.php</b> on line     <b>216</b><br />
<br />
<b>Notice</b>:  Undefined index:  p_format in <b>calculate.php</b> on line <b>220</b><br />

那为什么要这样做呢?有什么我需要改变(一个php.ini,配置)设置?它必须是PHP的东西

更新

我做了一个print_r($_POST);来查看是否有任何内容被发布并返回一个空数组

编辑:

客户端

if (current_tab == 0) {
    if (current_subtab == 0) {
        if ($("#saddle_brochure_copies").val() != "Please select...") {
            if ($("#saddle_brochure_copies").val().match('^(0|[1-9][0-9]*)$')) {

                if ($("#saddle_brochure_copies").val() != 25000) {
                    var new_copies = $('#saddle_brochure_copies option:selected').next().val(); //get next selected option for offer price
                }

                var p_copies = $("#saddle_brochure_copies"),
                    p_paper = $("#saddle_brochure_paper"),
                    p_paper_type = $("#saddle_brochure_paper_type"),
                    p_colours_t = $("#saddle_brochure_colours_t"),
                    p_pages = $("#saddle_brochure_pages"),
                    p_binding = $("#saddle_brochure_binding"),
                    p_format = $("#saddle_brochure_format"),
                    p_cover = $("#saddle_brochure_cover"),
                    p_cover_c = $("#saddle_brochure_cover_c"),
                    p_colours_fs = $("#saddle_brochure_colours_fs"),
                    p_colours_fs_c = $("#saddle_brochure_colours_fs_c"),
                    allFields = $([]).add(p_copies).add(p_paper).add(p_paper_type).add(p_colours_t).add(p_pages).
                                    add(p_binding).add(p_format).add(p_cover).add(p_cover_c).add(p_colours_fs).add(p_colours_fs_c),
                                    tips = $(".validateTips");

                $.post("order/calculate.php", {
                    current_tab_1: current_tab,
                    current_subtab_1: current_subtab,
                    delivery_options: delivery_options.val(),
                    p_copies: p_copies.val(),
                    p_paper: p_paper.val(),
                    p_paper_type: p_paper_type.val(),
                    p_colours_t: p_colours_t.val(),
                    p_pages: p_pages.val(),
                    p_binding: p_binding.val(),
                    p_format: p_format.val(),
                    p_cover: p_cover.val(),
                    p_cover_c: p_cover_c.val(),
                    p_colours_fs: p_colours_fs.val(),
                    p_colours_fs_c: p_colours_fs_c.val(),
                    new_copies: new_copies
                }, function (data) {
                    var resultArray = eval('(' + data + ')');
                    checkIfNull();
                    $(".value_2").append("&pound;");
                    if ($("#hf_quote").val() != null) {
                        $("#hf_quote").val(null);
                    }
                    $("#hf_quote").val(resultArray[0]);
                    if ($("#hf_vat").val() != null) {
                        $("#hf_vat").val(null);
                    }
                    $("#hf_vat").val(resultArray[1]);
                    cashFlow($('.value'), 0, resultArray[0], 1 * 1000, 0);
                    if (resultArray[1] != "No VAT on this product!") {
                        $("#quote_vat").append("&pound;", resultArray[1], " Inc. VAT");
                    } else {
                        $("#quote_vat").append(resultArray[1]);
                    }
                    if (resultArray[2]) {
                        if ($("#quote_offer").text() != null) {
                            $("#quote_offer").text("");
                        }
                        $("#quote_offer").append("Get ", new_copies, " copies for &pound;", resultArray[2]);
                    }
                });

的print_r($ _ REQUEST);返回 -

Array (
    [ppRemember] => 35iq0m8oi3ldr1f8603sifpv52 [__utma] => 201771013.995365705.1339148067.1339148067.1339155188.2 [__utmc] => 201771013 [__utmz] => 201771013.1339148067.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) [__utmb] => 201771013.9.10.1339155188
)

print_r($_GET);返回空数组

有问题的服务器端代码

if ($_POST['current_tab_1']==0) {
   if ($_POST['current_subtab_1']==0) {
    //for saddle stitched brochures
    //cost 1

    $format = strip_tags(substr($_POST['p_format'],0,100)); //format
    $B = strip_tags(substr($_POST['p_copies'],0,10)); //copies
    $C1 = strip_tags(substr($_POST['p_paper'],0,100)); //paper inner pages
    $C2 = strip_tags(substr($_POST['p_cover'],0,100));
    $lamination = strip_tags(substr($_POST['p_colours_fs_c'],0,100)); //lamination
    $P = strip_tags(substr($_POST['p_pages'],0,100));
    $new_copies = strip_tags(substr($_POST['new_copies'],0,100));

    }
}

更新

我试过echo $ _POST ['current_tab_1'];在脚本的顶部,它返回一个未定义的错误。

还注意到其中一个错误是这个......?

致命错误:在 975

计算.php 中调用未定义函数json_encode()

这是一个内置函数..对吗?

1 个答案:

答案 0 :(得分:0)

发现为什么一切都不起作用。尝试使用plesk控制面板将我的服务器从5.1.6更新到5.3,最终在安装过程中断了一半。当我终于让它再次工作时,我又回到5.1.6并决定再次进行更新。我认为这搞砸了我的php安装,因为在我成功更新到5.3后,一切都开始工作了。