jusmeig Posted July 10, 2008 Share Posted July 10, 2008 Please move this if I have posted in the wrong place. Im new to using curl. Basically what I want to do is the following in a php page: 1. GET a url (I have to visit this url to authenticate myself with the system I am using). Its a jsp page and I can see a sessionid getting set. Do I need to use this in the below? 2. I then need to POST a form with some values to run a search on a DB. 3. I then want to redirect the user to the result of this POST. Here is my code (Stripped down). I'm hoping I am missing something or have something wrong! $url = "url for authentication"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s $result = curl_exec($ch); // run the whole process $url = "form post url"; // set the target url curl_setopt($ch, CURLOPT_URL,$url); // howmany parameter to post curl_setopt($ch, CURLOPT_POST, 1); $postdata = "name=value&name=value"; curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $result = curl_exec($ch); curl_close ($ch); print $result; THANK YOU in advance! Link to comment https://forums.phpfreaks.com/topic/114097-some-help-for-a-curl-noob-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.