Is it possible to post to a form using php?
Moderator: General Moderators
Is it possible to post to a form using php?
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?
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.
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.