douqian5553 2014-05-10 11:43
浏览 44
已采纳

PHP - 如何在另一个文件中显示以表格形式输入的数据? [重复]

This question already has an answer here:

I have file1.php and file2.php. In file1.php I have made a form for adding news articles and when I press button "Submit" the entered data is sent to MYSQL base and page redirects to file2.php. What I want to do is to display this article in file2.php. How can I do that?

</div>
  • 写回答

2条回答 默认 最新

  • dongll0502 2014-05-10 11:58
    关注

    You have to use session for this purpose.As you not posted your code here so i am posting a sample.Let say this is your code.For more help.Check these links.1,2,3.

    file1.php

      <?php
      session_start();
      if(isset($_POST['article']))
      {
      //Then you add here in your MySQL
      //Similarly add them in the session so you can access the same data on your file2.php
        $_SESSION['article'] = $_POST['article'];
    
      //now redirect to file2.php
      }
      ?>
    
     <form action="#" method="POST">
    
     Article :<input type="text" name="article"/>
    
     <input type="submit" value="click"/>
     </form>
    

    file2.php

     session_start();
     if(isset($_SESSION['article']))
     {
          echo $_SESSION['article'];
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序