简体   繁体   English

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

[英]How to get and display input text from one page to another page

I have input field with some text in the page 我在页面中有一些文本输入字段

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

How can i display that value in other page? 如何在其他页面中显示该值?

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

a rough solution would be,, on firstpage.php 一个粗略的解决方案是在firstpage.php上

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

On secondpage.php, get values of input fields using $_POST['textinput'] and store it into session variable so now you can access it on any page 在secondpage.php上,使用$ _POST ['textinput']获取输入字段的值并将其存储到会话变量中,以便现在您可以在任何页面上对其进行访问

on secondpage.php 在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"];
?>

also check out this link to know more about php $_SESSION 还查看此链接以了解有关php $ _SESSION的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM