Reply to Re: [PHP] cURL to re-post form iinformation

Your name:

Reply:


Posted by "Richard Lynch" on 10/25/05 19:30

On Tue, October 25, 2005 8:36 am, Jay Blanchard wrote:
> 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?

cURL doesn't really interact with the browser directly here...

Your script is the "middle-man" between their form and FMSRegister.php

But they didn't surf to FMSRegister.php

Your script surfed there, but their browser didn't.

If you want their browser to surf there, you have to send "Location: "
headers, and you'd need to include whatever GET parameters you could
to make the request come out like you want, but, at that point,
there's not much reason for cURL to be involved...

I suspect you've over-estimated what cURL can do and what it's for...

All it does is let a program pretend to be a browser.

It doesn't let your program take over control of the user's browser.

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original 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

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