Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.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 如何将GET变量传递给窗体_Php_Forms - Fatal编程技术网

Php 如何将GET变量传递给窗体

Php 如何将GET变量传递给窗体,php,forms,Php,Forms,我有三页。其中之一是用户可以选择的文本列表。单击其中一个文本后,将使用以下命令将其重定向到另一个页面: <a href='second.php?text=whatever>Whatever</a> 一个页面,他们将输入他们希望发送这些文本到的用户名-使用表单。我希望进入第三页,介绍这两个变量-文本和用户名。我只能用用户名进入第三页 我得到了第三个.php?username=InputedUserName。 我想得到第三个.php?username=inputedUs

我有三页。其中之一是用户可以选择的文本列表。单击其中一个文本后,将使用以下命令将其重定向到另一个页面:

<a href='second.php?text=whatever>Whatever</a>

一个页面,他们将输入他们希望发送这些文本到的用户名-使用表单。我希望进入第三页,介绍这两个变量-文本和用户名。我只能用用户名进入第三页

我得到了第三个.php?username=InputedUserName。 我想得到第三个.php?username=inputedUserName&&text=which。 我知道我可以将文本存储到第二页的会话中,然后将其转移到第三页

我想知道是否有另一种安全的方法可以做到这一点——也许需要在action=thirdpage.php的形式中进行一些更改?我不知道。非常感谢。ö。ö


解决:在阅读了评论和答案之后,我需要的是type=hidden。我现在正在努力。谢谢大家帮助我

'second.php?text=which'
?你不能随便在课文上写什么,你做错了。试试这个

firstpage.php

<?php
    $whatever = 'Tom & Jerry, 1 + 2 = 3';
    echo '<a href="secondpage.php?text=' . base64_encode($whatever) . '">' . $whatever . '</a>';
?>
<form action="thirdpage.php" method="post">
    <input type="text" name="username" value="" />
    <input type="hidden" name="text" value="<?php echo base64_decode($_GET['text']); ?>" />
    <input type="submit" value="Submit" />
</form>
<?php
    echo 'Username: ' . $_POST['username'];
    echo '<br />';
    echo 'Text: ' . $_POST['text']; 
?>

secondpage.php

<?php
    $whatever = 'Tom & Jerry, 1 + 2 = 3';
    echo '<a href="secondpage.php?text=' . base64_encode($whatever) . '">' . $whatever . '</a>';
?>
<form action="thirdpage.php" method="post">
    <input type="text" name="username" value="" />
    <input type="hidden" name="text" value="<?php echo base64_decode($_GET['text']); ?>" />
    <input type="submit" value="Submit" />
</form>
<?php
    echo 'Username: ' . $_POST['username'];
    echo '<br />';
    echo 'Text: ' . $_POST['text']; 
?>


'second.php?text=whatever'
?你不能随便在课文上写什么,你做错了。试试这个

firstpage.php

<?php
    $whatever = 'Tom & Jerry, 1 + 2 = 3';
    echo '<a href="secondpage.php?text=' . base64_encode($whatever) . '">' . $whatever . '</a>';
?>
<form action="thirdpage.php" method="post">
    <input type="text" name="username" value="" />
    <input type="hidden" name="text" value="<?php echo base64_decode($_GET['text']); ?>" />
    <input type="submit" value="Submit" />
</form>
<?php
    echo 'Username: ' . $_POST['username'];
    echo '<br />';
    echo 'Text: ' . $_POST['text']; 
?>

secondpage.php

<?php
    $whatever = 'Tom & Jerry, 1 + 2 = 3';
    echo '<a href="secondpage.php?text=' . base64_encode($whatever) . '">' . $whatever . '</a>';
?>
<form action="thirdpage.php" method="post">
    <input type="text" name="username" value="" />
    <input type="hidden" name="text" value="<?php echo base64_decode($_GET['text']); ?>" />
    <input type="submit" value="Submit" />
</form>
<?php
    echo 'Username: ' . $_POST['username'];
    echo '<br />';
    echo 'Text: ' . $_POST['text']; 
?>


您是否尝试将文本作为
字段包含在第二页中?尝试将其添加到第二页表单
'second.php?text=which'
?你不能把任何东西放在文本中,你做错了。你为什么希望它是安全的?这是什么类型的内容?谢谢大家帮助我。所以我需要的是type=hidden。这对我来说很管用。您是否尝试将文本作为
字段包含在第二页中?尝试将其添加到第2页表单
'second.php?text=which'
?你不能把任何东西放在文本中,你做错了。你为什么希望它是安全的?这是什么类型的内容?谢谢大家帮助我。所以我需要的是type=hidden。这对我来说很管用。