FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Transfer data between pages on different servers?





imagefree
I want to transfer data and uploaded files between servers. Can someone tell me how?

Currently i know just 1 way, ie GET and works in this way

Code:
<?php include("http://sv2.site.com/pages.php?id=2&data=123456789"); ?>


i have never tried the above but i think it should work. I just want to ask is there any other way to transfer huge amounts of data (larger than 100 bytes because GET can support just 100 bytes) and files?

Can you please provide me a good tutorial.
Thanks
Hamid Sarfraz
Diablosblizz
Depends on the data, but you could use MySQL to store the data, then get the other Server to run a Cronjob and select all the table and then update it?

So, what I am trying to say is that all of your information is on one database. On a PHP script on the other server you select and update a database on your other server.

I hope this helps, and I hope you understand. If you don't, then post and I'll try to reword.
imagefree
no i just want to include a page but i want processing to be made on another server, so that data is submitted to the page and the page is acually php script. The script executes and returns result according to the given data. Is it possible without using GET?
Diablosblizz
Well, I am unsure. Possibly try it?
kv
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>
imagefree
kv wrote:
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>



yes this is OK in almost all of the cases except one, ie Searching. I will let user enter an ID and then the script on the main server will determine on which server the related data is saved and then forwards the data to the next server. Now for this situation, what do you suggest? Is it possible? How?
Stubru Freak
Take a look at at the curl functions.

Also, if the data is too big to be sent from server 1 to server 2, server 1 can send a URL where server 2 can download the data. But I think curl can do POST requests so that should be enough.
adeydas
imagefree wrote:
kv wrote:
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>



yes this is OK in almost all of the cases except one, ie Searching. I will let user enter an ID and then the script on the main server will determine on which server the related data is saved and then forwards the data to the next server. Now for this situation, what do you suggest? Is it possible? How?


if you are using forms, POST request is always better than GET request because GET request can only handle data sent in the URL whereas POST can handle form data.
Stubru Freak
adeydas wrote:
imagefree wrote:
kv wrote:
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>



yes this is OK in almost all of the cases except one, ie Searching. I will let user enter an ID and then the script on the main server will determine on which server the related data is saved and then forwards the data to the next server. Now for this situation, what do you suggest? Is it possible? How?


if you are using forms, POST request is always better than GET request because GET request can only handle data sent in the URL whereas POST can handle form data.


A GET request can also handle form data. Set the method attribute to GET.
imagefree
Stubru Freak wrote:
adeydas wrote:
imagefree wrote:
kv wrote:
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>



yes this is OK in almost all of the cases except one, ie Searching. I will let user enter an ID and then the script on the main server will determine on which server the related data is saved and then forwards the data to the next server. Now for this situation, what do you suggest? Is it possible? How?


if you are using forms, POST request is always better than GET request because GET request can only handle data sent in the URL whereas POST can handle form data.


A GET request can also handle form data. Set the method attribute to GET.


yes both do almost the same thing except, using GET data is visible and is limited to 100 bytes.
kv
imagefree wrote:
kv wrote:
It is possible as long as you are not using session across servers. You can use html form to transfer the data with full url in the action.

Code:

<form action='http://sv2.site.com/pages.php'>
.... <!-- your data here -->
</form>



yes this is OK in almost all of the cases except one, ie Searching. I will let user enter an ID and then the script on the main server will determine on which server the related data is saved and then forwards the data to the next server. Now for this situation, what do you suggest? Is it possible? How?


You can use javascript in this case. Instead of having a default action on the form, use javascript to submit the form. Something like this.

Code:

<script ...>
function submitform()
{
//pseudo code
if(id>=0 && id<1000)
   action="http://sv1.site.com/pages.php";
else if(....)
   action="http://sv2.site.com/pages.php";
...etc...
testform.action=action;
testform.submit();
}
</script>

<form name=testform>
.... <!-- your data here -->
  <input type=button onclick="javascript:submitform();" /> 
</form>


One issue here might be that the main server may be dynamically determining the server depending on id. In that case the javascript may be dynamically generated instead of having id ranges hardcoded.
imagefree
thank you for another usefull suggestion. This is solution of one problem. But i have another problem. Using multiple servers, my system will require the transfer of data from 1 server to another server. I am asking for the solution of that problem.


Just suppose, i want to save all the uploaded files to server 1, and after some times when the user becomes Addicted to my site, the files uploaded by that user is transfered to another server and also some variables are to be transfered. I am asking the solution of this scenerio.


Hope now you can understand what i am asking about.
Stubru Freak
As I said earlier, take a look at at the curl functions.

Also, if the data is too big to be sent from server 1 to server 2, server 1 can send a URL where server 2 can download the data. But I think curl can do POST requests so that should be enough.
imagefree
but it requires additional installation and Compiling PHP again etc type problems, and my script may not be compatible to all situations.
Stubru Freak
imagefree wrote:
but it requires additional installation and Compiling PHP again etc type problems, and my script may not be compatible to all situations.


Most PHP installations will already have it. It's certainly the easiest way to achieve server communication.
kv
One option is to open the server2 url (using file open functions, like opening a file) and write data into it. On server2, the script which handles the url should be able to open input stream and read from it. I have done this before using jsp and servlet, but am not sure how to do it using php. You can look at php streams php://in and php://out, but as Stubru Freak suggested, using curl may be the easiest solution.
Related topics
Booting time
Programming links, info, and tutorials
Which is the best Mobile phone
Store all your data on Google servers
how to transfer data from one host to another?
PHP Question - Solved
Pages sometimes not loading
Windows XP Tricks & Tips!!!!
How to transfer daa between 2 computers
how 2 connect to my other pc without going over the net
What do I need to go wirelessinternet on laptopw/out range
help with connecting printers, scanners and drives
INTERNET BASICS [CHAPTER - 1]
Transferring data through wireless routers(wireless network)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.