I want to send a message from my website to my other four websites

Look at the image first - I have a total of four websites. I want to send a message from my original website to three separate websites. There are four websites with separate domain names and hosting and each is built on PHP. If it is not possible to tell the code, tell me how to learn a scheme and try to work with what method.

Have a read up on CURL, that’s an easy way that your PHP code on your sender web site could send a message to your other sites. Have some code on each of the receivers, and use CURL to submit your message to it.

Obviously you’ll want some security on the connection, so that your receiving sites can be sure that it’s your site sending the information.

You do not tell us what determines when the messages are sent. Is it just one way, just from the original website to the other three or is there more involved? Is it periodical or is there some other event that determines when to send? Because it can be frustrating when someone gives ans answer and the the person that wants help says it won’t work because of something they did not mention.

If it is done periodically then you could have a web service running in your original website then the other sites could send a request periodically and the web service could respond. Web services are called many other things too. I suppose for PHP you will want to see PHP: Web Services - Manual.

Your three other websites could establish a TCP/IP connection with your original site and then the original site could use that to send the messages. I do not know much about the details of that. It might be possible for the one website to create temporary TCP/IP connections with the other sites and send messages.

Another option is UDP. With TCP/IP the message is guaranteed to get sent and received but with UDP you do not have that guarantee. If you do not need the guarantee then UDP is easier.

I think PHP: stream_socket_client - Manual is used to open the TCP or UDP connection and other functions are used from there. You can look for articles about those. I think the following might be relevant but I do not know for sure.

yes, all my sites making with php. Can you tell me how to do the job? And what is this process called?

Have a read through the CURL documentation, if that will suit your needs, and see how far you get with it. Also is anything in the post by @SamuelCalifornia going to be relevant to when and how you send the messages?

Using CURL:
On each of your three receiving servers, have a web form processing script, just like you would if a user was connecting directly to them from a browser and typing the information in. Instead, post that information from the script running on your sending server.

First job is to create one of the form processing scripts on one of the receiving servers, and get that storing information correctly using a form to populate it for now. Plenty of documentation and sample code on this if you’re not familiar with it.

Next job, write the script on the sending server to post the data directly. Plenty of sample code around on how to use CURL, with the added benefit that you’re in control of both ends.

Once you have both of those working, all you need to do is copy the form processing script to your other receiving servers, with any needed changes, and edit the sender to publish to all three.

But it might be worth saying what your goal is on a wider scale - if it’s just database replication, I know MS SQL server can do that itself, and I have an idea later versions of MySQL can too.

1 Like

My approach would be simple. If you have 4 different websites and have access to MySql just create a new db and use that db as a central portal to connect the 4 websites mail program you create. That’s what I would do. It would be secure and messages would be stored.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.