Saturday 15 May 2010

php - Post to remote file without a form -



php - Post to remote file without a form -

without using form, possible _post different file?

in case, want send string via _post, file.

thanks.

update:

based on response post, used this:

<?php $ipcreation = $_server['remote_addr']; $ipcreationcurl = curl_init(); // initiate curl $url = "accountcreation.php"; // want post info curl_setopt($ipcreationcurl, curlopt_url,$url); curl_setopt($ipcreationcurl, curlopt_post, true); // tell curl want post curl_setopt($ipcreationcurl, curlopt_postfields, $ipcreation); // define want post curl_setopt($ipcreationcurl, curlopt_returntransfer, true); // homecoming output in string format $output = curl_exec ($ipcreationcurl); // execute curl_close ($ipcreationcurl); // close curl handle var_dump($output); // show output ?>

this returns:

"308 moved permanently" "nginx"

what's error? thanks.

you can post using curl. here basic example: http://devzone.co.in/post-data-using-curl-in-php-a-simple-example/

$ch = curl_init(); // initiate curl $url = "http://www.somesite.com/curl_example.php"; // want post info curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_post, true); // tell curl want post curl_setopt($ch, curlopt_postfields, "var1=value1&var2=value2&var_n=value_n"); // define want post curl_setopt($ch, curlopt_returntransfer, true); // homecoming output in string format $output = curl_exec ($ch); // execute curl_close ($ch); // close curl handle var_dump($output); // show output

php

No comments:

Post a Comment