rygonet Posted May 11, 2007 Share Posted May 11, 2007 Okay, so I have: <input type="hidden" name="__FIELDPUT" id="__FIELDPUT" value="/abunchofrandomnumbersandvarshere" /> How do I put "abunchofrandomnumbersandvarshere" in a variable? Here's what I got so far (by the way, abunchofrandomnumbersandvarshere is random and can be anything). if(preg_match("/id=\"__FIELDPUT\" value=\"(.*)\" /s", $html, $matches)) { $viewstate = $matches[1]; } echo $fieldput; I know this is wrong.. Link to comment https://forums.phpfreaks.com/topic/50974-quick-regex-question/ Share on other sites More sharing options...
chigley Posted May 11, 2007 Share Posted May 11, 2007 If that form's method is POST, just use $_POST['__FIELDPUT'] to get the value of it in PHP. Link to comment https://forums.phpfreaks.com/topic/50974-quick-regex-question/#findComment-250785 Share on other sites More sharing options...
effigy Posted May 11, 2007 Share Posted May 11, 2007 <pre> <?php $html = '<input type="hidden" name="__FIELDPUT" id="__FIELDPUT" value="/abunchofrandomnumbersandvarshere" />'; if(preg_match('/(?<=id="__FIELDPUT" value=")([^"]*)/', $html, $matches)) { print_r($matches); $var = $matches[1]; } echo $var; ?> </pre> Link to comment https://forums.phpfreaks.com/topic/50974-quick-regex-question/#findComment-250789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.