I have never needed to do this before, but I am developing an application which will be installed to a users website - but it will need to query data held in a database stored on the application's server.
Server A (client - domian: www.example.com)
Server B (application).
There will be a form on Server A (a Search form) which POSTS search data to the Server B (application) along with some information about Server A (domain, IP).
Server B handler will:-
1.) Check if Server A is an actual client (i.e. is domain (www.example.com) in the allowed domains list and does the request come from the IP of Server A.
2.) If 1.) is TRUE, it will process the request, and return a response being the results of the query.
I can't seem to find anything on Google or this site where someone wants to do this? I could be searching for the wrong thing though.
Also, would there be any limits on the size of the array that is returned back to Server A??
I do not want to grant DB access to the user - unless this is the only solution (i.e. create a new mysql DB user with READ only capability upon activation of the application).??
Any help much appreciated
IF you're posting data to server b (the db host) then the query will be run locally on that server.
What you need is some script that can handle your post OR if you want to connect to the db from server A and also handle the post i server A then you have to give that server the right to connect to the db-server.
So then thing you need to do is to write a script on the server B that will handle the post.
My guess is that you're better of giving server A (proper)access rights to the db on server B.
Related
I have 2 servers, let's call them server A and server B. Server A is publicly hosted and has a public facing front-end. Users can visit a page on Server A and submit a form, which needs to be submitted to a page hosted on a private network that Server A does not have access to Server B, however does have access to said private network.
What I need to achieve, is for Server A formulate the request and then execute it from Server B, so that it can hit the page on the private network. The flow would be:
1. User submits form
2. Server A formulates an HTTP request and passes it to Server B
3. Server B executes the HTTP request and passes the result back to Server A
3. Server A acts upon the result of the executed request
The solution I have so far come up with is to have Server B host a PHP built API-like interface with 1 function: ExecuteHTTPRequest(targetURL, requestBody, parameters). Server A will then call this function, passing in the URL it wants to hit, the body of the request, and any additional parameters that have been set, and receive the result of the request, as if it had executed it itself.
The downside of this solution is that it means opening up access on an entire port on Server B for this specific purpose (albeit only from Server A), and that a web server is required to be running on Server B. So, I'm wondering if there is some other solution that might be more appropriate?
What is the best alternative to synchronize an app on Windows Mobile 6.5 with SQL Server Compaq with an php aplication on a PC server.
The phone does not always have internet access beacouse coverage issues, also can be connected to a PC via USB.
The data are in a table in SQL Server Compaq on the phone, the data are text and a number, associated through an identifier. This is updated from time to time where there is no internet connection. Then this data update a database in SQL Server 2008 on a server that has internet access.
There is also the possibility to update the phone's data table from the server to add more data to be updated in the field.
I hope you understand me because English is not my native language.
I was thinking of using exchange to send emails with updated data or use a service like dropbox to keep an updated file and that file is processed.
Which approach is better?
I hope you can guide me.
thank you very much.
If you are running a SQLClient on the CE device that connects to a SQL server, the best solution is to use the SQL synchronization options. This is also called RDA, see for example: http://etutorials.org/Programming/building+solutions+with+the+microsoft+net+compact+framework/Part+II+Essential+Architectural+Concepts/Chapter+7.+Data+Synchronization/RDA/
If the databases on the device and on the server are not connected, the automatic ID generation on the device and the server create different unique IDs. These will result in a conflict, when you update the data from multiple sources. If you do not need to handle conflicts with multiple sources updating the same database, you may simple send the updates between the server and the client and vice versa on regular intervals using http GET/POST or simple socket server/client.
Usually sometimes disconnected devices use http or another network protocol to pull and push updates. Files are rarely used for push/pull updates.
As you used the php TAG for this question too, using http with a php server with a database in the background, you can use php to extract data sent via GET/POST and also provide data back to the device using xml (or another format).
I have two PHP servers. Let's call them local server and remote server.
A user logs into a website on local server but when a link is clicked, data is to be retrieved from the remote server.
The remote server requires a login before the data can be accessed. The login is done via POST.
I've been able to perform a POST from local server to remote server successfully and have received the successful login page. However, when the necessary data is requested, the remote server acts as if there is no login session.
I suspect this is a problem with PHP session IDs not matching up. My reason for thinking this is I think the remote server is obtaining the local server PHP session ID and not finding a match and therefore acts as there is not a valid login.
How can I keep the remote session alive to enable the data to be retrieved?
Use one database & table for sessions. On the local server manage it (store & update) and when requesting data from remote pass a variable in the POST called session & check it with database.
I have set up a website with basic HTML/CSS files and would like to take that one step further and implement a database with some PHP to perform simple queries and whatnot.
My problem arose when I noticed while setting up the database and creating the PHP files that connect to the database (on my local machine), I used 'localhost' as an argument for mysql_connect. When I then went to drag and drop my newly created HTML/PHP files along with my database into FileZilla to upload the pages onto my remote server, there was a problem connecting to the database. I have a feeling that it is unhappy with the whole 'localhost' notion - yet I don't know what to change it to.
Currently, I am using this line of PHP code to connect to my remote database (which is all located in FileZilla-land).
$link = mysql_connect('localhost','Tommy','pass')
Also, as another quick question: does my remote server have its own phpMyAdmin page? And if so... how would one go about finding it? =D
I appreciate anyone who is able to assist me in my endeavors.
Thank you!!
Log on to your database server, check the details and obtain the correct server information such as server, username and password.
Once you change the server details you shoudl be ready to rock n roll. Edit post with the host name/server name and we may be able to find it for you.
You'll have a phpMyAdmin page where you're hosting the site. Check the membership area or cPanel.
You are right in that 'localhost' in mysql_connect needs to be different. 'localhost' is a textual representation of a loopback address AFAIK - it connects to the computer it is hosted on. As you have uploaded it to your server (a different computer) it is now trying to connect to a mysql server on the server host, instead of your home computer (which holds all the data).
To make this work you'd need to get your database onto the server you are now working from, OR depending on your home setup, point it to your local database.
Whether your host has MySQL/PHPMyAdmin available to you is another matter altogether. If they have MySQL it is probable but not definite that they have a phpmyadmin interface.
Contacting the server host will yield more information. If they have MySQL, it is probably as simple as getting the required details from them, and 'backing up' your SQL on your local server and uploading it to the new server (easily done with PHPMyAdmin)
TL;DR: The database you are trying to connect to doesn't exist on the server you're connecting from.
I have a login form on one server, server A. Hosted on another server, server B, I have a script to check the data and return the result. Server B sends the result to server A, but I don't want to pass the result back in the URL or headers with various redirects, because people can spoof a "true/false" to change the result of the login.
e.g.
I can't use HTTPS/SSL as my web host does not support it for free.
You could set up an ssh tunnel between the servers and have the web server on B listen only on localhost:Bs_tunnel_port, while A connects to its localhost:As_tunnel_port.
Or get that SSL thing going... ;)