senyo Posted October 27, 2009 Share Posted October 27, 2009 Is there a way to send data to another server like using POST from a form? I want to send data from my localhost to a server automatically without a form Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/ Share on other sites More sharing options...
Alex Posted October 27, 2009 Share Posted October 27, 2009 You can accomplish this using cURL Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945755 Share on other sites More sharing options...
senyo Posted October 27, 2009 Author Share Posted October 27, 2009 Where can I find an example? Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945756 Share on other sites More sharing options...
Alex Posted October 27, 2009 Share Posted October 27, 2009 There is good information available on the link I posted. You can also try http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html or Google. Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945760 Share on other sites More sharing options...
senyo Posted October 27, 2009 Author Share Posted October 27, 2009 I found this: <?php if(isset($_POST['Name'])) $Name = $_POST['Name']; if(isset($_POST['Email'])) $Email = $_POST['Email']; if(isset($_POST['Message'])) $Message= htmlentities($_POST['Message']); $Curl_Session = curl_init('http://www.site.com/cgi-bin/waiting.php'); curl_setopt ($Curl_Session, CURLOPT_POST, 1); curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "Name=$Name&Email=$Email&Message=$Message"); curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1); curl_exec ($Curl_Session); curl_close ($Curl_Session); ?> I don't know curl so I assume that $Name is the subject $Email the email address $Message the content. http://www.site.com/cgi-bin/waiting.php the address where this is sent Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945769 Share on other sites More sharing options...
Alex Posted October 27, 2009 Share Posted October 27, 2009 The contents is irrelevant. Basically what that is doing is sending data to that url. If you look at the string "Name=$Name&Email=$Email&Message=$Message", that's what's being sent. On the other end it would be captured like a standard post. ex. echo $_POST['Name']; Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945774 Share on other sites More sharing options...
senyo Posted October 27, 2009 Author Share Posted October 27, 2009 Thanks, you have been very helpful Quote Link to comment https://forums.phpfreaks.com/topic/179257-solved-how-to-post-data-automatically/#findComment-945782 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.