开发者社区> 问答> 正文

PHP POST表单失败,目标页无法接收,怎么办?

我想通过这个代码实现试卷试题的生成,通过循环生成了单选题目,并想通过数组POST给验证页面进行评分,但是我发现无法获取check[]数组,也无法POST到目标页面。
作为新手,目的是想实现功能,因此代码很冗杂- -
quesid[$i]数组可以正常传递给目标页面。
真心求教。
代码如下:

<? require ("../css/css.php");?>

session_start(); if(isset($_SESSION['id'])){ $admin = $_SESSION['id']; $query = "select * from admin_info where admin_id = '$admin'"; //select admin information $result = mysqli_query($dbc,$query); $rows = mysqli_fetch_array($result); $admin_name = $rows['admin_name']; $admin_id = $rows['admin_id']; echo "
"; echo ''.$admin_name.'('.$admin_id.')您好!
'; } ?> //get sql test information $query = "select * from test_info where test_number = '000'"; $result = mysqli_query($dbc,$query); $rows = mysqli_fetch_array($result); $update_name = $rows['update_name']; $test_number = $rows['test_number']; $test_name = $rows['test_name']; $class_one = $rows['class_one']/100; $class_two = $rows['class_two']/100; $class_three = $rows['class_three']/100; $danx_quantity = $rows['danx_quantity']; $duox_quantity = $rows['duox_quantity']; $pand_quantity = $rows['pand_quantity']; $test_uptime = $rows['test_uptime']; $test_start = $rows['test_start']; $test_end = $rows['test_end']; $test_duration = $rows['test_duration']; $test_status = $rows['test_status']; ?>
echo '
'.$test_name.'
'; echo '注意:
&nbsp &nbsp &nbsp 1.你有'.$test_duration.'的时间答题,请把握好时间;
&nbsp &nbsp &nbsp 2.理论考试包含有单选题:'.$danx_quantity.'题、多选题:'.$duox_quantity.'题、判断题:'.$pand_quantity.'题;
&nbsp &nbsp &nbsp 3.各部分内容所占比例为,政治理论基础:'.($class_one*100).'%、 条令条例:'.($class_two*100).'%、军兵种常识与军事高技术:'.($class_three*100).'%。
'; ?>

一、单项选择题
$danx_quantity; $class_one_num = round(($danx_quantity*$class_one),0); $class_two_num = round(($danx_quantity*$class_two),0); $class_three_num = ($danx_quantity - $class_one_num - $class_two_num); //科目一 for($id = 1,$sub_id = 1,$c1_id = 1;$sub_id &nbsp'.$question_cont.'

'; echo ''; echo '&nbsp &nbsp A.'.$danx_choiceA.'
'; echo '&nbsp &nbsp B.'.$danx_choiceB.'
'; echo '&nbsp &nbsp C.'.$danx_choiceC.'
'; if($danx_choiceD != NULL){ echo '&nbsp &nbsp D.'.$danx_choiceD.'
'; } else { echo '
'; } echo ''; echo '
'; echo "----------------------
"; } //科目二 for($sub_id,$id,$c2_id = 1;$sub_id "$question_id"); $ques_id[$id] = $question_id; echo '['.$ques_id[$id].']'; echo '&nbsp'.$question_cont.'

'; echo ''; echo '&nbsp &nbsp A.'.$danx_choiceA.'
'; echo '&nbsp &nbsp B.'.$danx_choiceB.'
'; echo '&nbsp &nbsp C.'.$danx_choiceC.'
'; if($danx_choiceD != NULL){ echo '&nbsp &nbsp D.'.$danx_choiceD.'
'; } else { echo '
'; } echo ''; echo '
'; echo "----------------------
"; } //科目三 for($sub_id,$id,$c3_id = 1;$sub_id &nbsp'.$question_cont.'

'; echo ''; echo '&nbsp &nbsp A.'.$danx_choiceA.'
'; echo '&nbsp &nbsp B.'.$danx_choiceB.'
'; echo '&nbsp &nbsp C.'.$danx_choiceC.'
'; if($danx_choiceD != NULL){ echo '&nbsp &nbsp D.'.$danx_choiceD.'
'; } else { echo '
'; } echo ''; echo '
'; echo "----------------------
"; } ?>
for($i = 1;$i "; } ?>


返回上级| 退出登录

POST目标页面:test_check.php
<?

for($i=1;$i <=100;$i++)
{
$check[$i] = $_POST['check'][$i];
$ques[$i] = $_POST['quesid'][$i];
}
print_r($check);
echo "
";
print_r($ques);
?>

展开
收起
小旋风柴进 2016-03-06 15:14:12 2575 0
1 条回答
写回答
取消 提交回答
  • 生成的数组使用json_encode()函数转化为字符串传递给验证页面,验证页面使用json_decode()方法再转化为数组,再在验证页面中执行验证操作。

    2019-07-17 18:54:41
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-深入浅出网络编程与swoole内核-吴镇宇 立即下载
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载