If I have a wordpress website, and a user on the website enters some survey information, is it possible to send the results to a local server inside a company (assuming the website is hosted on some other companies server). From looking around I see people using the JSON formats and GET, PUT etc.. but I havent seen this demonstrated with wordpress. Is there a standard way to do this? I can see it is possible to send via emails, but I was hoping for something more like TCP/IP communications
If it must run through the front-ends WordPress installation, then the easiest way to be a simple HTTP POST request to a server you control. PHP has several different ways you can accomplish this with minimal effort.
The other way you can do this is just to set up a form that will send an AJAX response to your server. Just make sure your receiving server is configured to allow the originating domain.
Related
I’m making new a static website for a client, and they are wanting a contact form that a user could fill out and it will send the enquiry to the clients email.
The client is currently using cPanel as their web host manager, on what I believe is an Apache server. I don’t actually know what server side language that it would be using as I don’t have access to their cPanel account.
I was initially thinking I could create a PHP script that would use the mail() function, and I would put that into the public_html folder with the rest of the static site, and so when the user submits a POST request, the forms action will call that PHP script.
But from what I’ve read, that isn’t the best way to go about it and instead I should be using an Simple Mail Transfer Protocol (SMTP). I have a vague idea of what this is from googling, but have no idea how to implement such a thing.
I’m typically used to creating sites with React.js/ Gatsby.js, Node.js, Netlify, and so I’ve had no experience with cPanel and the like.
Has anyone done something similar or has any advice? Any thing will be much appreciated!
I think the first step is to get many information as you could about the available server structure. It is very hard to elaborate on any good solution without having control and/or knowledge about the server-side: maybe a tool or resource you use for implementing an SMTP-based solution could not be available to you when deploying it.
You could try to argue with your client on the importance of knowing the server structure. Use arguments on quality of service, security, among others.
If you get the server information, consider use PHPMailer if the server provides you with the required resources and dependencies.
If you could not have that information, the solution you think first ( use mail() ) will probably work. Great discussions about the topic occurred here.
However, firstly ensure that the server offers email sending service. It would be hard if it does not offer that service, but it is a possibility.
I have a main website (with backend SQL database), and I have satellite websites which are all separate domains. Each of these websites are hosted by a provider and have their own SQL databases, however, I don't want to maintain 6 or 7 different databases. Instead I would like just one centralised one.
What I would like, is that when a user submits a form on one of the satellite websites, the data is able to get transmitted and stored in the database of the main website. May have to be via a special URL or something - I really don't know.
Is this possible and if so, how?
I think AJAX may have something to do with it, but I cant seem to get to grips with it and it doesn't seem to work for me. SO I'm hoping this is possible using simple PHP. Any help would be appreciated.
Thanks in advance.
On the server where you are hosting the database, you can setup a PHP web service that would receive post requests from the remote forms and do the communication with the database. You can pass in your post request some extra parameters to differentiate between sources from which the requests are coming.
You will have to be extra careful with such a design idea, as your script would be receiving cross domain requests from different sources and might be prone to CSRF attacks unless you take some extra security measures by validating the sources and forms from which the requests are coming.
In addition to the above mentioned solution, you can also simply allow your sattelite sites to connect to your database directly if such a remote DB connection to your server is supported/enabled.
You can have your satellite sites connect to your central database directly as well. They don't have to be on the same servers.
All you need for that to work is a user account on your DB server which allows access from other addresses than localhost.
Yes, it's certainly possible, and probably better to do it server side with PHP rather than client side with AJAX, because on the client you'll run into XSS issues. You'll probably need to build your own API endpoints, and I suggest looking at this article for more info on making the requests.
You can generate post requests and submit to any domain. That's not a problem. Doing cross site requests can be problematic, but would like to see your code!
I was wondering if i could easily access my PHP files on a different server other than the one currently being used by my website. I would like to do this so i won't have to give certain scripting files to my client and have the client access them from my own server. If it is possible, how can i set my files' permission so the client can easily access them.
thank you in advance.
There is something called CSRF Cross Site Request Forgery. It is basically a way through which you can prevent what you just asked for: Accept requests from remote forms. But, you want to provide this feature. So, instead of directly accepting form POSTs, you can provide an API to selected users you choose to, by authenticating them before providing them Access. But you will have to write code for the client so that he can use your API.
XML-RPC is somewhat related to what you want too. You should check it out.
So I was asked to look at reconstructing a section of a website which I didn't build. One of the issues I'm running into is a contact form which is being loaded through an iFrame from another server. Obviously, the form's action submits to the other server, and the information is stored in a database for the client to see later.
I've never had to deal with something like this before and I'm wondering if I need to go through some sort of API the host may be able to provide, or can I recreate the form so I can style it and just have it submit to the same server. Sorry for the noob level of this question, but I'm just looking to be pointed in the right direction.
While what you are planning to do, technically works (I have done it myself on several occasions), it is possible the remote host might reject POST data from locations other than itself.
For example, if your site is running at www.example.com and the host site is running www.host.com The server running at host.com will be able to determine if you are sending POST data from example.com. This again, is only a problem if they are cross site checking.
Since you don't have access to their server to know, you will just have to try it and see.
Actually, this type of reject might or might not happen: Since a server needs to read the referrer to reject, but the referrer isn't sent by each and any browser.
Additionally, beware of protection mechanisms like session ids. Or some kind of authorization hash injected into forms as a hidden field.
I am trying to develop a analytic s project. My goal is to let a owner of x-domain be allowed to copy and paste a small snippet of javascript includes on to their site, from my server. That will be able to analyze the end users experience on their site.
Given that my server is php, and I will sending and recieving data larger then the browser max limit, my question is...
Does only 1 server need to have the web proxy In order to make a successful exchange of data ? (i.e. can the x-domain send data back to me and not require a proxy as well?)
Since I am only gathering data from the x-domain, I only need for x-domain to send me data. There is no need for my server to send data to it. Since I am using php/apache for my server. will I only need configure php to setup this proxy in order for javascript to send the data.
I notice that yahoo developers network got sample code for setting up a web proxy. Could I use this for my own use and own work ? Are there any good resources out there to get me start on doing this correctly ?
Thanks for you guys responses. I appreciate it.
You should not need any proxies. You should also not be using ajax, but be passing data to a hidden "<img>" in the page. This is how the Google gets around the cross-domain issue: they load a "gif", only it's not really a gif, but just simply a path to their server which feeds user data as it happens.
This may be your best bet to get around the cross-domain issue.