ian2k01 Posted May 26, 2009 Share Posted May 26, 2009 I'm not too familiar with parsing function, or preg_match, need help with parsing simple HTML. Here is the code: <input type="hidden" name="SessionID" value="12433690503231243369050323U[[bR??=96<692"> I would like to parse out the value, and set it as a variable. Thank you so much! Link to comment https://forums.phpfreaks.com/topic/159773-parsing-html/ Share on other sites More sharing options...
ionik Posted May 26, 2009 Share Posted May 26, 2009 Are you submitting this to a form? If so use $_POST['SesssionID']; If you want the Regex for this here it is $str = '<input type="hidden" name="SessionID" value="12433690503231243369050323U[[bR??=96<692">'; preg_match_all('/value="(.*)"/i', $str, $match); echo '<pre>'; var_dump($match); echo '</pre>'; echo $matches[1][0]; Link to comment https://forums.phpfreaks.com/topic/159773-parsing-html/#findComment-842687 Share on other sites More sharing options...
ian2k01 Posted May 26, 2009 Author Share Posted May 26, 2009 Actually I think I need the Regex. But there are more than just one <input type="hidden" ...> on the page. if I only want the SessionID, do i use: $str = '<input type="hidden" name="SessionID" value="12433690503231243369050323U[[bR??=96<692">'; preg_match_all('/name="SessionID" value="(.*)"/i', $str, $match); echo '<pre>'; var_dump($match); echo '</pre>'; echo $matches[1][0]; Link to comment https://forums.phpfreaks.com/topic/159773-parsing-html/#findComment-842691 Share on other sites More sharing options...
aschk Posted May 27, 2009 Share Posted May 27, 2009 Hmm session jacking by chance? Link to comment https://forums.phpfreaks.com/topic/159773-parsing-html/#findComment-843021 Share on other sites More sharing options...
ian2k01 Posted May 27, 2009 Author Share Posted May 27, 2009 Sorry not sure what jacking means. The original code I wanted to preg was <input type="hidden" name="SwtAcctID" value="_____"><input type="hidden" name="SessionID" value="12434392951101243439295110U[[bR??=96<692"><input type="hidden" name="IsSuperUser" value="FALSE"><input type="hidden" name="IsGroupUser" value="FALSE"><input type="hidden" name="IsAdminUser" value="FALSE"><input type="hidden" name="PageAppList" value="<APPLIST><APP id="qfind" caption="Quick Find" url="qfPaymentInquiry" pageType="static"></APP></APPLIST> But then it grabbed everything until the end. So a friend of mine modified the preg with a "?": preg_match_all('/name="SessionID" value="(.*?)"/i', $str, $match); The code works now, thank you guys! Link to comment https://forums.phpfreaks.com/topic/159773-parsing-html/#findComment-843233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.