You are here: cURL to re-post form iinformation « PHP « IT news, forums, messages
cURL to re-post form iinformation

Posted by Jay Blanchard on 10/25/05 16:36

Howdy all,

I am trying a new technique, for me, when processing a form. The form is
filled out and submitted, during processing it is determined that there is
an error with the posted data...such as a blank or mismatched password,
I want to return the form with the data filled out using curl....as a test I
did this....

/* curl post test */

$post_data['username'] = $_POST['username'];
$post_data['password'] = $_POST['password'];
$url = "http://TEST20051010/FMSRegister.php";

/* assemble POST data in string */
$pd="";
foreach ($post_data as $k=>$v){
$pd.= "$k=".$v."&";
}
$post_data=substr($pd,0,-1);

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);

curl_close($ch);

Now, this works OK...save for one little problem that I cannot seem to
figure out. The URL now reads

http://TEST20051010/NameOfProcessingScript.php instead of
FMSRegister.php.

I am searching the curl options http://www.php.net/curl_setopt but have not
found what I am looking for. Can someone clue me in?
Thanks!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация