tags:

views:

29

answers:

1

Hi,

i've got to connect 2 php pages on 2 different servers,

in the first server there's the DB (mysql) with an "email" table, generated by a php page.. in the second server there's a php file wich needs to read the "email" table...

the second php page doesn't need to be opened by the user

the fact is that i need to make this work with lots of DB, not just one so i can't store the mysql connection params in the php page on the 2nd server and just open it... i've got to pass the connection params every time

For now i use something like this, on the 1st server php page:

$socketcon = fsockopen("http://www.server2.com",80,$errorno,$errorstr,10);

if($socketcon) { 
  $socketdata = "GET page2.php?dbuser=xxx&dbpass=xxx&db=xxx  HTTP/1.0\r\nHost: http://www.server2.com\r\nConnection: Close\r\n\r\n"; 
  fwrite($socketcon,$socketdata); 
  fclose($socketcon); 
}

but i fear that putting the params in URL is soooo bad....

any idea ?

A: 

One way to do is to create a "public" webservice with PHP that will receive credentials. If the credentials match you reply with the data you need (maybe in XML format). Of course all of this is over HTTPS. You can then "talk" with the service with CURL to create you DB connexion.

AlexV
hmm, since i can't store anything on the second server, i'll have to use the same credentials for every connection i have to make...and is passing db credentials by curl more secure ?
Il_pasqui
It will be more secure if you use CURL over an HTTPS connection.
AlexV
is doing the fsockopen() through ssl and sending data in POST form a viable option ?
Il_pasqui
AlexV
ok, thanks, time to get to work !! :D
Il_pasqui