如何在PHP的3页之间获取变量
我有3页的PHP page1.php如何在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
<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'];
}