curl-and-php
RE: Receiving Curl POST data.
From: B Z <bz029_at_hotmail.com>
Date: Thu, 06 Jul 2006 20:29:24 -0700
Date: Thu, 06 Jul 2006 20:29:24 -0700
Try adding an echo at the end, like so:
<?php
$post = Array();
$post[1] = urlencode('test1');
$post[2] = urlencode('test2');
$post[3] = urlencode('test3');
$curl = curl_init("post.php");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($curl);
curl_close($curl);
ECHO $response;
?>
From: Josh <ja-robison@wiu.edu>
Reply-To: curl with PHP <curl-and-php@cool.haxx.se>
To: curl-and-php@cool.haxx.se
Subject: Receiving Curl POST data.
Date: Thu, 6 Jul 2006 00:35:43 +0000 (UTC)
>I have been attempting to create some software that requires a login, with
> php/gtk. I am using a site that only allows local connections to my
>mysql database using localhost with scripts that are connected.
>This software will be a .exe when finished so I need a way of
>passing variables to a script online. I started looking at CURL
>in PHP. I made a sample script from something I found online,
>but when executed I get a blank page.
>Can anyone suggest what I am doing wrong?
>
>Here is the script for the first page:
>
><?php
>$post = Array();
>$post[1] = urlencode('test1');
>$post[2] = urlencode('test2');
>$post[3] = urlencode('test3');
>
>$curl = curl_init("post.php");
>curl_setopt($curl, CURLOPT_POST, 1);
>curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
>$response = curl_exec($curl);
>curl_close($curl);
>?>
>************************************END FIRST SCRIPT
>Here is the post.php script:
>
><?php
>$p = $_REQUEST['post'];
>echo "CONTENTS:";
>echo "$p";
>?>
>****************************END SECOND SCRIPT
>This code is rediculously simple looking...
>I even tried $_POST['post'] instead of request but nothing
>came out on the page when executed....
>I found this earlier and I just need help to figure out what is
>wrong and then I can go from there and
>develop my more advanced script..
>
>Can anyone help?
>
>
>_______________________________________________
>http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-07-07