简体   繁体   English

同时打开两个PHP页面之间传递数据

[英]Pass data between two php pages while both are opened

I have some PHP files in some project. 我在某些项目中有一些PHP文件。 This project contains two main parts. 该项目包含两个主要部分。 These are "Admin" and "user". 它们是“管理员”和“用户”。 My project folder is much likely: 我的项目文件夹很可能是:

C:\xampp\htdocs\project

Say I have an admin panel page named "admin_panel.php" in such directory C:\\xampp\\htdocs\\project\\admin\\admin_panel.php 假设我在这样的目录C:\\xampp\\htdocs\\project\\admin\\admin_panel.php有一个名为“ admin_panel.php”的管理面板页面

as well as I have also a user page named " user_file.php " in such directory 在该目录中还有一个名为“ user_file.php ”的用户页面

C:\xampp\htdocs\project\user\user_file.php

Both files are opened in two browsers say in chrome and firefox. 在chrome和firefox这两个浏览器中都打开了这两个文件。

Now I want to pass some notification with yes/no button from " admin_panel.php " to " user_file.php ". 现在,我想通过“是/否”按钮将一些通知从“ admin_panel.php ”传递到“ user_file.php ”。 Whenever " user_file.php " get that content, one can press yes/no and this data is needed to send to " admin_panel.php " to take proper action. 只要“ user_file.php ”获得该内容,就可以按“是/否”,并且需要将该数据发送到“ admin_panel.php ”以采取适当的措施。

How these can be done. 这些怎么做。 Any answer will be appreciated. 任何答案将不胜感激。 Thanks in advance :) 提前致谢 :)

You could use "Sessions" with PHP, which you can update with AJAX 您可以在PHP中使用“会话”,然后可以使用AJAX更新

            $.ajax({
              method: 'POST',
              url: 'somephp.php',
              data: {
                'someinfo': info,
                'ajax': true
              },
              success: function(data) {
                      //if you want to do anything else
              }
            });

PHP Code: PHP代码:

<?php
   session_start();
   $_SESSION["info"] = $_POST["info"];
       //or what ever
?>

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

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