0

I would like to allow a set of users to be able to submit a form on one page, and then it would cause an event to trigger on another page. For example:

Submit Page: Includes the form, the user submits the form

Alerts Page: Displays information from the form on every instance of the page that is open across the world.

So I am basically sending a live message to that page, but I have no idea how to go about doing this, I am experienced in web design but have never done this sort of thing before. I assumed you could not use sockets as this would need the users IP that is viewing the page and I want everyone viewing that page to have the text appear. Not sure what sort of system I need to use/how I go about doing this.

  • 2
    I would use websockets. I don't work in php so don't know an answer but googling for 'websockets php' brings up a lot of resources. – Scott Mildenberger Mar 25 '19 at 22:11
  • If the users with the page open do not need the update to occur in the same few seconds that its send by the first user (like how a chat client works), then the easiest path would be to have the open pages do AJAX polling every so often to look for new alerts to be displayed. – Graham Mar 26 '19 at 14:26
  • How to do it is a fairly too broad question. Where to start a simpler one to answer. Something for you to start with Push technology and Pull technology – Laiv Mar 26 '19 at 15:01
1

You need to use simple ajax function that would keep pooling from a server for new alerts. websocket is good alternative here, but you can do that with normal ajax http calls.

When the form is submitted from Submit Page, it would save the message in a table on server, say: notifications.

On your alerts page, you would keep checking every 5-10 seconds (you can decide), if there is any message from available in notifications table. Once it gets a message, it stores it and displays on the screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.