Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.