dourenzhou8740 2016-01-20 16:25
浏览 17

如何确保我的表单在PHP中以数组形式出现

The idea is that when you click on Volgende, to $getal1, $getal1, $soort, and $antwoord are put in an array. If this is the 2nd time, it 1st and 2nd time there come to be.

THIS IS MY PHP CODE IN ENGLISH

<?php   
$kind = $_SESSION['kind'];//get the kind of  task choose from +-/*
$class = $_SESSION['class'];//get the number of class
$answers = $_SESSION['answers'];//get the previous answers
if($class == "klas4"){
    $max = 10;
}
if($class == "klas5"){
    $max = 20;
}
if($class == "klas6"){
    $max = 100;
}
$number1 = mt_rand(0,  $max);
$number2 = mt_rand(0,  $max);
?>
<div class="som">
    <form action="" method="post">
        <?php echo $number1 . $kind . $number2 ?>
        <input name="answer" type="number">
        <input type="submit" name="next" value="next"> 
    </form>
</div>
<?php    
    if(isset($_POST['next']))
    {   
    $answer = $_POST['next'];
    $answers=array($answers);
    array_push($answers,$number1,$kind, $number2,$answer);

    var_dump($answers);
    $_SESSION['answers']=$answers;
    }
?>

If this code is executed, everything comes together.

I hope someone can help

  • 写回答

1条回答 默认 最新

  • drtzb06222 2016-01-20 16:46
    关注

    Try making your code in English btw, I'm Dutch so I can read it but it's bad practise to do it in your own language.

    Also the reason it doesn't work is because $antwoorden isn't defined. You don't do any calculation. You save $antwoorden but never get it out of the session again.

    can you just post the whole script? I think you use 1 php file.

    I also think you should be more clear in what the script should do.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号