Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending data from PHP using POST

Status
Not open for further replies.

rastkocvetkovic

Programmer
Aug 11, 2002
63
SI
Is there a possibility of sending data from PHP using POST. To see, what I mean, I'll try to describe an example.

I have two servers.
On nr.1 database with data and nr.2 with no data.
Now I want to have a page named nr1.com/transmit.php, where I click transmit and page redirects to nr1.com/transmit_exec.php which retrieves the data from the database and transmits those variables using POST (due to very long texts, which cannot be add to URL as GET) to nr2.com/get_data_and_put_it_into_database.php.

I hope it's clear what I would want to do. I hope you know the solution. Thank you in advanced for you answers.
 
What is a possibility to get data from nr1.com to nr2.com:
1. nr1.com has a script called nr1.com/fetch_write_data.php that fetches the data from db and writes it to a plain text file called data.txt.(need to set a dir to write permissions for this).
2. nr2.com needing the data somewhere in the code adds the line
include(' and then
$hfile = fopen(' 'r');
/*
filesize() doesn't work on remote files so set bytes to
read manually and big enough 1MB?; fread stops at EOF
*/
$data = fread($hfile, 1000000);

Now you have the data available at nr2.com and can do with it what you like...echo to user or parse the text and insert it into database, etc.
 
The easiest way is probably to use CURL or to manually do it.
I've personally never used CURL, but there are a lot of threads about this in this forum. Doing it manually has also been shown in other threads. Make a quick search for CURL on this forum and you should get more information //Daniel
 
Binaryshi, your method works fine. I've made a .txt file that is transferred and evaluated later that time. But I've found out that such method doesn't fully fulfill my needs.
But the problem persists when nr2.com doesn't know which server is nr1.com - which could be a notebook under firewall - localhost server. Therefore we'll need to find another solution. :(
As Curl is concerned, I didn't manage to get into it, but I surely will, after the sleep.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top