| |||||||||||
| |||||||||||
Extracting html form input elements Posted by millisami (millisami), 30 April 2006 This is the html page which is stored in $content variable. (Its only a snippet of the overall html page)Code:
The following is the code I'm using. I want it to put all the value of attributes, i.e. for this example, value of name and value attributes to $matches array. The above input html contents plus other contents are stored in $content variable. Code:
And when I do the var_dump($matches), its empty. Could you please suggest me a way out how to alter the pattern to get the desired result for me. Thanks in advance. Posted by admin (Graham Ellis), 1 May 2006 I'm confused as to whether you're setting up a PHP page with variables to be filled in, or trying to extract fields being returned.If filling in, preg_match only matches - use something like preg_replace. If extracting, use the $_REQUEST superglobal variable to pick up the values. As a side thought, it's not good practise to have a lot of hidden fileds in your form - it makes the pages long and you leave yourself open to users editing the HTML and submitting forged data - for example to changing a price. Have a look at sessions and use a single hidden value and the initial question become irellevant too. Have a look at the session demo at http://www.wellho.net/resources/ex.php4?item=h115/sc6.php and the preg_replace at the end of it This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |