I have multiple news/blog websites that have article pages containing a form. One of the hidden values in this form pertains to the topic of the article. For example, if it's an article on farming, I'd like the form to be added to a farming mailing list.
Initially, I created a form on a corporate domain and tried to include it (via a PHP include) on the article websites. But I then realized that's bad practice and not allowed by our host to do remote PHP includes.
I then tried to host the same PHP file locally on each website, but have it access the same database hosted on the corporate server. However, this is throwing errors as well. Remember that the database needs to be accessed in order to query for the right e-mailing list based on the topic. And the idea is to just keep one database updated rather than many.
My question is: What's the best way to accomplish this? Is there a way to access a database located on server A via a PHP script on server B?
Treat this like you would any client-side javascript talking to a server to get some data from a database: A simple mysql script that accepts some (optional?) parameters, runs the query, then repackages the data into a suitable transmission format. For direct PHP-to-PHP communication, you could use serialize(), but that has issues if you're working in a mixed 32bit/64bit environment. JSON is another good option.