dongyoucha0645 2015-03-28 20:54
浏览 36

带有复选框数组的PHP代码在实际站点中不起作用,但在本地主机中有效

English is not my native language; please excuse typing errors.

I have a very strange problem with a PHP code, using checkbox arrays. It is a simple checkbox code in a real site in Russian language, where I help to my frend to fix: http://astrabis.ru/teoria/test2.php

The host has the PHP Version 5.3.13.

But this code, YES, works in my local PC (Windows 7, with installed Xamp Appache) PHP Version 5.6.3. I has been installed the PHP server to debug the problem that I describe here.

Problem description. The check boxes in the file test2.php is shown perfectly on a browser, but when I check some of them and press Submit, the server does not move any data to testrez2.php file that processes the data.

Details. In file test2.php there are three arrays of check boxes: vata[] pita[] kapha[] The test2.php code fragments:

<!DOCTYPE html>
<html>
<head>
...
<meta http-equiv=Content-Type content="text/html; charset=windows-1251" /><meta name=viewport content="width=device-width, initial-scale=1" />
...
</head>
...
<form action="http://www.astrabis.ru/teoria/testrez2.php" method="post">
...
<table cellspacing="1px">
<tbody>
<tr><td rowspan="3">????</td><td><input name="vata[]" type="checkbox" value="2">???????, ??????????; ???????????, ??????????? ?? ???????? ?????????, ???????????? ????????, ??????? ? ??? ?????? ? ? ??? ??????.</td></tr>
<tr><td><input name="pita[]" type="checkbox" value="2">???????????, ?????????????????, ????????????, ?????? ????, ????? ???????. ???????????? ???. ???????????? ???????? ? ????, ???? ??????? ??????? ???? ?? ????????????????? ????????.</td></tr>
<tr><td><input name="kapha[]" type="checkbox" value="2">?????????, ??????, ??????????, ?? ???????????? ???????.</td>
...
...
<tr><td rowspan="3">?????</td><td><input name="vata[]" type="checkbox" value="2">??????????? ? ????? ? ???????????.</td></tr>
<tr><td><input name="pita[]" type="checkbox" value="2">??????????? ? ?????????? ???????????, ?????? ?????????.</td></tr>
<tr><td><input name="kapha[]" type="checkbox" value="2">??????????? ? ????????????? - ????????,???????? ? ?.?.</td>
</tr>
</tbody>
</table>

The file of the result processing, testrez2.php, has some simple matematic, but I added some debug code to see the input data and other info The testrez2.php code fragments:

...
<?php
echo "<br>vata : ";
print_r(array_values($_POST['vata']));
echo "<br>pita : ";
print_r(array_values($_POST['pita']));
echo "<br>kapha : ";
print_r(array_values($_POST['kapha']));

$x=0;
$y=0;
$z=0;

if (isset($_POST['vata']))
{$x=array_sum($_POST['vata']);}

if (isset($_POST['pita']))
{$y=array_sum($_POST['pita']);}

if (isset($_POST['kapha']))
{$z=array_sum($_POST['kapha']);}

$sum=$x+$y+$z;

//debug
echo "<br>x : $x";
echo "<br>y : $y";
echo "<br>z : $z";
echo "<br>sum : $sum";

More of that, historically, I started to debug another file from the site and added the same code in a file testrez3.php, (it is activated by test3.php of the same real url). It is the same debug printing code that is shown in the file testrez2.php above.

The pair test3.php and testrez3.php are worked several days and stopped with the same problem!

I also shanged the method from POST to GET in files test2.php testrez2.php (). I wanted to see in the address line of my browser Chrome that the checkbox data is really sent to the server. It is sent! But the testrez2.php also does not receive any data.

See below the match of two "gets": real site and my PC local host

localhost/astrabis/astrabis.ru/test/testrez2.php?vata%5B%5D=2&pita%5B%5D=2&kapha%5B%5D=2&vata%5B%5D=2&pita%5B%5D=2&kapha%5B%5D=2

astrabis.ru/teoria/testrez2.php?vata%255B%255D=2&pita%255B%255D=2&kapha%255B%255D=2&vata%255B%255D=2&pita%255B%255D=2&kapha%255B%255D=2

  • 写回答

1条回答 默认 最新

  • duanchuang3182 2015-03-28 21:24
    关注

    Look at the difference:

    pita%5B%5D=2
    

    locally vs:

    pita%255B%255D=2
    

    if you urldecode pita%5B%5Dyou will get pita[] but the other one is double urlencoded, if you decode it once you will get pita%5B%5D. That is your problem. You should check where that double urlencode comes from. I don't see anything in the code you posted so maybe some server setting.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错