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条)

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上