Jump to content

Parsing HTML


ian2k01

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.