Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP的3页之间获取变量_Php_Html - Fatal编程技术网

如何在PHP的3页之间获取变量

如何在PHP的3页之间获取变量,php,html,Php,Html,我有3页的PHP page1.php <form method="post" action="page2.php"> <input type="number" name="x"> <button type="submit" name="submit2">submit</button> 提交 page2.php <?php if (isset($_POST['submit2'])) { $n = $_POST['x

我有3页的PHP

page1.php

<form method="post" action="page2.php">
    <input type="number" name="x">
    <button type="submit" name="submit2">submit</button>

提交
page2.php

<?php
if (isset($_POST['submit2']))
{
    $n = $_POST['x'];
}
else
{
    echo "num wasn't obtained?"
}
?>

<form method="post" action="page3.php">
    <?php for ($i=0; $i < $n ; $i++) { ?>
    <select name="text<?php echo $i+1 ?>" required>
        <option value="asdf">asdf</option>
        <option value="qwer">qwer</option>
    </select>
    <?php } ?>
    <button type="submit" name="submit3">submit</button>

隐藏表单字段或会话。你能告诉我怎么做吗?当你得到适当的关键字时,你能先做你自己的研究吗?
$l$i
无论如何都是无效的。为什么不直接执行
,然后在第3页上,您可以只执行
变量转储($\u POST['text'])
,然后查看如何获得数组?漂亮!
<?php
if (isset($_POST['submit3']))
{
    for ($i=0; $i < $n; $i++) #where $n is x from page1.php 
    {
        $l$i = $_POST['text$i'];
    }