i'm trying scan form, , pull out fields not type="hidden" , retrieve name="" value, i'm using
@<input.*?>@
which retrieves following me,
( [0] => array ( [0] => <input type="email" id="contact0email" name="email" class="field" onfocus="if ($(this).val() == $(this).attr('title')) { $(this).val('') }" onblur="if ($(this).val()=='') { $(this).val($(this).attr('title'));}" title="enter valid email here" value="enter valid email here"> [1] => <input type="submit" class="submit" value="get instant access"> )
however not need code, i'd have scan further need, suggest regular expression should use need? in example there no hidden fields, there may in others need run for.
here quick , dirty solution you:
$string = '<form name="input" action="html_form_action.asp" method="get"> <input type="hidden" name="foo" value="123"/> username: <input type="text" name="user" value="ralph"> pass: <input type="text" name="pass"> <input type="submit" value="submit"> </form>'; $doc = new domdocument(); $doc->loadhtml($string); $input = $doc->getelementsbytagname('input'); ($i = 0; $i < $input->length; $i++) { $el = $input->item($i); if ($el->getattribute('type') === 'hidden' || $el->getattribute('type') === 'submit') continue; echo $el->getattribute('name') .':'.$el->getattribute('value')."\n"; }
Comments
Post a Comment