Page 1 of 1
Is it possible to post to a form using php?
Posted: Thu Jun 08, 2006 4:33 pm
by Li0rE
Hello. I would like to post to a form using php. I dont mean make a form and then have it post to a php script, I mean being able to post information to another php script from my php script. I think this has something to do with curl?
Posted: Thu Jun 08, 2006 4:37 pm
by PrObLeM
yep curl will do the trick
Posted: Thu Jun 08, 2006 4:39 pm
by Li0rE
yes well as I said in this:
viewtopic.php?p=270916#270916 thread, how do I use curl. It isnt too clear on php website.
Posted: Thu Jun 08, 2006 4:57 pm
by PrObLeM
this should get you started:
Code: Select all
$url = "http://www.EXAMPLE.com/folder/file.php"; //Url to php file
$vars = "var1=val1&var2=val2&var3=val3"; //Post variables with values
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$data = curl_exec($ch);
curl_close($ch);
echo $data; //This will be what ever the php file returns.
Posted: Thu Jun 08, 2006 5:14 pm
by Li0rE
thanks!