SUBMIT FORM AFTER LOGIN PHP CURL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
radio86
Forum Newbie
Posts: 4
Joined: Mon Mar 01, 2010 9:01 am

SUBMIT FORM AFTER LOGIN PHP CURL

Post by radio86 »

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

Code: Select all


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.8 ) 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);
Post Reply