Jump to content

Search...and a little more!


mynameismud

Recommended Posts

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. :(
Link to comment
https://forums.phpfreaks.com/topic/4697-searchand-a-little-more/
Share on other sites

[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.
Link to comment
https://forums.phpfreaks.com/topic/4697-searchand-a-little-more/#findComment-16914
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.