radio86 Posted January 6, 2011 Share Posted January 6, 2011 Hi Guys I can login into the site, a session is created and stored in cookies.txt but i dont know how to begin the next step where the script needs to submit another form in the members area on the same website. basically the plan is, i create my own form and send data to curl script which will login into external website form, create session, then send data created from my own form to to external website members form page. This way i will be able to store the data on my database and sent to them. But now i am lost. Please help me, thanks in advance function getData($data) { $query = ""; foreach ($data as $value => $name) { $query.=$value."=".$name."&"; } return $query; } $var = substr(getData($_POST),0,-1); $headers = array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0. Gecko/20061025 Firefox/1.5.0.8"); // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://site.com/page.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=radio86&pass=phpfreaks'); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/cookies.txt"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec ($ch); Quote Link to comment Share on other sites More sharing options...
lastkarrde Posted January 7, 2011 Share Posted January 7, 2011 where the script needs to submit another form in the members area on the same website The cURL "client" (as such) is remembered by the server because of the COOKIEJAR/COOKIEFILE and the fact that a session is stored on the server. Submitting another form in a login protected area shouldn't be a problem. Just be sure to call your authentication function before your do-something-when-authed function. Quote Link to comment 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.