auto filling a form with php/curl..

noonesland

New member
Jan 19, 2010
27
0
0
I have a question im writing a script to autofill a sign-up form but the form is split up into four pages. So the first one wants you to accept an agreement and then it redirects you to a register form where it ask for name and password then it redirects to the 3 page asking for your blog name and such. "its lifetype cms if your wondering..." I look at the headers as I manually filled it out and it sends a post 4 times separatly...So do you have to break it down like this...


curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/register..start1");
$post ="accept agreement"
curl_setopt($ch1, CURLOPT_HEADER, 0);
$post ="username=blah+password=hello";
curl_setopt($ch2, CURLOPT_URL, "http://www.example.com/register.php");
curl_setopt($ch2, CURLOPT_HEADER, 0);
 


I was trying to follow a php script by smaxor that he does with wordpress but I'm a little lost with the multiple header posts with this certain form.
 
How fast do you need this script to be, and does it have be in php? If not, you might want to think about using browser automation to accomplish your goal(watin/watir... Ubot...).
 
....

well im teaching myself php and curl and how to emulate a form right now, so if possible i would like to learn how to script it in that language. but thanks for the quick reply.
 
I got the first one, that's how i know it does 4 different header posts. But have never heard of firebug...i check it out. Thanks for the help.
 
my question is i have researched the links and played with different variations of curl setup ops and still have not figured out, would there be anyone that could give some sample code that you would use to submit to a multi form signup..?
 
My blog contains a little guide of scraping with PHP and cURL. There are five sections, here's a link.

This should get you a good base on how to use cURL and what the differences between GET and POST are and how to do the basics. All form requests use some sort of GET or POST to the server to transfer the data, whether it's direct like a form element on the page or through say through AJAX.

All submitting to a multi form signup is, is passing the proper variables and values to another script. A good understanding of HTML and even Javascript will go a long way.
 
You will possibly need cookie functionality enabled also - CURLOPT_COOKIEJAR / CURLOPT_COOKIEFILE

Also, watch out for ajax requests as these don't show in live http headers. YOu need to use the Net panel in Firebug
 
You will possibly need cookie functionality enabled also - CURLOPT_COOKIEJAR / CURLOPT_COOKIEFILE

Also, watch out for ajax requests as these don't show in live http headers. YOu need to use the Net panel in Firebug

Actually yes they do show up in live http headers.
 
You're really probably better off building a class with a curl in there as well as a dom document, form objects with query string variables that can be set and a submit method for each form. I did this but I lost the code. If you do that then it's easy to emulate pretty much anything that doesn't involve javascript in 2 minutes or so. All you need is the starting URL and the names of the fields that need to be filled at each step before calling submit.

That might be confusing. If I ever rewrite my browser emulator class I'll post it.
 
Have a look at the sfBrowser class in symfony, it basically simulates a browser in php, may do what you want