简体   繁体   中英

How can I pass data from one page to another?

So regarding my question I have two pages. Page1.php to save customer sale information and Page2.php to display the sales(Page2 is connected to a monitor in our office no user interaction, no keyboard, no mouse).

.

In Page1 the users can save information about customer sales. For example product name. The users user is always connected to the sale. After submitting the sale, I want it to show up on Page2., and says something like: User Demitri just sold a PS4 .

What have I tried so far :

Now when the user register sale, it saves into a MySQL table, and the Page2. automatically refreshes( <meta http-equiv="refresh" content="10"/> ) the page every 10 second to see if any new record has been added to the table. If a new record is there, it will display the user and the product that was sold on the page for 30 seconds, example: User Demitri just sold a PS4 , and then it will remove the record from the table, and then refresh the page again to see if any new record has been added to the table.

What do I want to accomplish:

I want a sort of system that can be used to pass data from Page1. to Page2, without needed any user interaction on Page2, and don't need to have a auto refresh script that runs every 10 second. This also looks bad because every time it refreshes, the website will sort of blink.

This is a very cumbersome process to do it, there must be some other way?

我会推荐使用 dB 来存储数据,需要该数据的页面可以查询数据.. 也许使用 ajax、fetch 和一些 setinterval 函数

  1. Use ajax, so you don't have to refresh the page every 10 seconds.
  2. Use websockets. Once you notice a new sale, you just push it and then your connected page can display it. This would be the best way i think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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