Re: convert hidden form to get url

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Reeves wrote:
> Anyone got any suggestions on the best way to convert the snippet of code
> below (which I'm dynamically collecting from another website) to a get url
> (i.e.
> http://www.somewebsite.co.uk/Availability?NUM_OF_ADTS=1&CABIN=E&B1_DAY=27
> )
>
> <form action="http://www.somewebsite.co.uk/Availability.cgi"; method="POST"
> name="flightsForm" id="flightsForm">
> <input type="hidden" name="NUM_OF_ADTS" value="1"/>
> <input type="hidden" name="CABIN" value="E"/>
> <input type="hidden" name="B1_DAY" value="27"/>
> </form>

Errrr.

You do realize that the other web-site has a REAL GOOD probability of not
responding to the GET URL at all, or at least not correctly, right?

And that if you Google for "Rasmus PostToHost" you'll find a function that
lets you send POST data to that other website, just as if you had filled
out the form "by hand", right?

So I can't begin to see *why* you would want to convert to GET style...

That said, you should be able to use http://php.net/preg_match to find all
the type="hidden" bits, and then another preg_match to find the name="..."
bits, and another preg_match to find all the value="..." bits.

One tricky part is that they *could* flip-flop the order of the name/value
parts and still be in HTML spec.  So you need to decide if it's worth
worrying about that, or if they are consistent enough to not do that, and
you can just ignore that wrinkle.

There also could be inputs that are things the user actually *types* and
you'd need to detect those and program something useful to go into them.

Also be sure, in any case, that you send the name/value on the Submit
button as well -- Some applications rely on that being there to work.

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux