Presto-X Posted July 6, 2010 Share Posted July 6, 2010 Hello everyone, I’m working on a script to log user’s on one of our site’s to the mySQL database running on another one of our sites, we would like to keep track of domain, ip address, and time stamp. What would be the best way to submit this information from one site to the other? I was looking at a script today that would submit POST data from one site to another using sockets, I was not able to get this script working, so I’m asking on here for your ideas. I know I could simply use a form and submit it via post or get but I do not want the user’s page to have to leave the current site and then back again, not sure if there is a simple way to do this or not. PS. I don’t care if it’s POST, I’m not attached to the way we send data just as long as we can send the domain the user is on and their ip address. Quote Link to comment https://forums.phpfreaks.com/topic/206827-send-data-from-one-site-to-another-sites-mysql-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 6, 2010 Share Posted July 6, 2010 So, you did not actually provide us with any information about how these sites are hosted. Are they hosted at the same web host and do they have access to the same database server? Quote Link to comment https://forums.phpfreaks.com/topic/206827-send-data-from-one-site-to-another-sites-mysql-database/#findComment-1081665 Share on other sites More sharing options...
Presto-X Posted July 6, 2010 Author Share Posted July 6, 2010 Thanks for the reply PFMaBiSmAd, It would depend on the site, in most cases it would not be on the same server. I did some more Googling and found this tut: Sending POST form data with php CURL I got it working using the following script: session_start(); define('POSTURL', 'www.remotedomain.com/connection.php'); define('POSTVAR_DOMAIN', 'domain='.$_SERVER['HTTP_HOST']); define('POSTVAR_IPADDRESS', '&ipaddress='.$_SERVER['REMOTE_ADDR']); // INITIALIZE ALL VARS $ch=''; $Rec_Data=''; $Temp_Output=''; if($_SERVER['REQUEST_METHOD']==='POST') { // REQUIRE POST OR DIE $ch = curl_init(POSTURL); curl_setopt($ch, CURLOPT_POST ,1); curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVAR_DOMAIN.POSTVAR_IPADDRESS); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL $Rec_Data = curl_exec($ch); ob_start(); header("Content-Type: text/html"); $Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20"); $Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output)); $Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output); $Temp_Output = substr($Temp_Output,307,200); echo $Temp_Output; $Final_Out=ob_get_clean(); echo $Final_Out; curl_close($ch); } else die('Hacking attempt Logged!'); exit; Quote Link to comment https://forums.phpfreaks.com/topic/206827-send-data-from-one-site-to-another-sites-mysql-database/#findComment-1081669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.