htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Sending POST request with CURL
PostPosted: 21 Feb 2007 21:49 
Offline
User avatar

Joined: 25 Sep 2006 04:48
Posts: 242
It is a very handy thing to be able to send POST data from a form to a script. Normally you would do this using a form on an XHTML page like
Code:
<form action="/cgi-bin/form-control.php" method="post">
<input type="hidden" name="secretvar1" vale="date123" />
</form>

This would send the POST data secretvar1=date123

To do the same thing from php using curl you can use this code.

Code:
function Relay_Post($Post_Url){
    $Curl_Session = curl_init($Post_Url);
   curl_setopt ($Curl_Session, CURLOPT_POST, 1);
    curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "Name=$CLN_Name&Email=$CLN_Email&Message=$CLN_Message&FormName=$CLN_Form_Name&CallBack=$CLN_CallBack&CallNumber=$CLN_CallNumber&CallTime=$CLN_CallTime");
    curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
    curl_exec ($Curl_Session);
    curl_close ($Curl_Session);
   
   return;
}



This sends the variables Name=$CLN_Name&Email=$CLN_Email&Message=$CLN_Message&FormName=$CLN_Form_Name&CallBack=$CLN_CallBack&CallNumber=$CLN_CallNumber&CallTime=$CLN_CallTime to the $Post_Url


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB