mynameismud Posted March 11, 2006 Share Posted March 11, 2006 Hi all, been lurking for a while and tried some coding with limited success.I'm looking to write some code that will display content (from an XML source) depending on whats in the URL/Address Bar. An example of this could be [a href=\"http://www.asite.com/fetch.php?=cars\" target=\"_blank\"]http://www.asite.com/fetch.php?=cars[/a]Does this make any sense? Basically a searchbox on another page would send the user to a page with the url above, the page shown would pull XML source according to the bit following the '?'Can anyone help, i've set up a phpBB board, but this is way beyond me. :( Quote Link to comment https://forums.phpfreaks.com/topic/4697-searchand-a-little-more/ Share on other sites More sharing options...
txmedic03 Posted March 13, 2006 Share Posted March 13, 2006 [code]if ( substr($_GET['srch'], strrpos($_GET['srch'], '.')+1) == "xml" ) { $source = implode('\r\n', file($_GET['srch'])); if ( strlen($source) > 0 ) { echo $source; } else { echo "<p>No results to display.</p>\r\n"; }} else { echo "<p>Can not return source for that type of file.</p>\r\n";}[/code]This assumes the name of the form field that contains the url is srch. This uses the file extension xml as the only possible source to return to keep people from being able to get source to php files and such which you may not want them to have. Quote Link to comment https://forums.phpfreaks.com/topic/4697-searchand-a-little-more/#findComment-16914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.