php - how to auto fill and submit html form with curl -


i want auto fill html form , submit form , display result. used below code got here.

<?php //create array of data posted $post_data['email'] = 'myemail'; $post_data['pass'] = 'mypassword';  //traverse array , prepare data posting (key1=value1) foreach ( $post_data $key => $value) {     $post_items[] = $key . '=' . $value; }  //create final string posted using implode() $post_string = implode ('&', $post_items);  //create curl connection $curl_connection =    curl_init('http://m.facebook.com/');  //set options curl_setopt($curl_connection, curlopt_connecttimeout, 30); curl_setopt($curl_connection, curlopt_useragent,    "mozilla/4.0 (compatible; msie 6.0; windows nt 5.1)"); curl_setopt($curl_connection, curlopt_returntransfer, true); curl_setopt($curl_connection, curlopt_ssl_verifypeer, false); curl_setopt($curl_connection, curlopt_followlocation, 1);  //set data posted curl_setopt($curl_connection, curlopt_postfields, $post_string); //perform our request $result = curl_exec($curl_connection);  print $result; //show information regarding request echo curl_errno($curl_connection) . '-' .                  curl_error($curl_connection);  //close connection curl_close($curl_connection); ?> 

and used facebook mobile site , gmail test code.

i placed url of login page of sites in curl_init function, gave value of name attributes of username , password fields of login page keys of $post_data array , saved code my.php file , placed in xampp htdocs directory in local machine.

when browse my.php, displays login page username field filled , password field not filled. according code, expected result is, should return logged page because have provided correct username , password. curl_errno returns 0. means no error occurred. why can't expected result? , why password field not filled although username field filled?

inspecting code @ http://m.facebook.com/ see there hidden fields may (should) try send. there prevent automated post.

first http://m.facebook.com/ , hidden fields using dom parser , build query post them action url.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -