Jump to content

Archived

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

mynameismud

Search...and a little more!

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. :(

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.