如何从一个页面获取和显示输入文本到另一个页面

时间:2016-06-30 09:24:52

标签: javascript php jquery wordpress

我的输入字段包含页面中的一些文字

http://localhost/example/package-details/?v=package1/

如何在其他页面中显示该值?

http://localhost/example/book-now/?v=package1/

1 个答案:

答案 0 :(得分:0)

粗略的解决方案是, 在firstpage.php

<form action="secondpage.php" method="post">
  <input type="text" name="textinput">
  <other inputs>
  <input type ="submit" value="submit">
</form>

在secondpage.php上,使用$ _POST [&#39; textinput&#39;]获取输入字段的值并将其存储到会话变量中,现在您可以在任何页面上访问它

on secondpage.php

<?php
 // Start the session
 session_start();
 // Set session variables
 $_SESSION["textinput"] = $_POST['textinput'];
 //access this session variable
 echo "value of textinput is  " . $_SESSION["textinput"];
?>

还可以查看此链接,了解有关php $_SESSION

的更多信息