BRUm Posted August 30, 2007 Share Posted August 30, 2007 Hello, I'm trying to use curl_init() and curl_setopt() to send some data via POST to another script where it will be parsed. This script is basic, yet I don't understand why it's not working. My experience with cURL functions is little. Here's the main script which sends the data: <? $path = "form.php"; //Relative path to the file with $_POST parsing $ch = curl_init($path); //Initialise curl resource with above file $data = "submit=submit&name=bob&age=100"; //Data to be sent to the file curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //Send the data to the file? curl_close($ch); //Close curl session ?> Here's the recipient script which parses the request, and on success should make a directory named "success". I have tested the directory creation without the first script, as I thought it may be permission problems, however everything in that area is fine. <? if($_POST['submit']) { print "Your name is ".$_POST['name']." and your age is ".$_POST['age']; mkdir("C:/Users/Lee/Desktop/xampp/htdocs/PHP/".$_POST['name']); } ?> When executing the first script I receive noting but a blank screen. I tried curl_exec($ch); to generate some output yet it gave nothing of use. Any help would be greatly appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/67273-using-curl-to-send-post-requests/ Share on other sites More sharing options...
btherl Posted August 30, 2007 Share Posted August 30, 2007 Try using the full url to the script instead of just "form.php" Quote Link to comment https://forums.phpfreaks.com/topic/67273-using-curl-to-send-post-requests/#findComment-337502 Share on other sites More sharing options...
BRUm Posted August 30, 2007 Author Share Posted August 30, 2007 I've tried that. By the way I am using a local server on my PC which has cURL enabled. Quote Link to comment https://forums.phpfreaks.com/topic/67273-using-curl-to-send-post-requests/#findComment-337637 Share on other sites More sharing options...
sKunKbad Posted August 30, 2007 Share Posted August 30, 2007 http://www.phpit.net/article/using-curl-php/2/?pdf=yes you are missing CURLOPT_POST curl_setopt($ch, CURLOPT_POST, true); Quote Link to comment https://forums.phpfreaks.com/topic/67273-using-curl-to-send-post-requests/#findComment-337678 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.