views:

74

answers:

1

Guys,

Here is my website : http://searchr.us/web-search.phtml

So now,once anyone searches in that page it comes like this :

http://searchr.us/web-search.phtml?search=SEARCHED+TEXT

So now what i want to do is that when a person searches anything for that matter.A page with its title called

http://searchr.us/web-search.phtml?search=SEARCHED+TEXT.html

Or something like that which has the keywords in the title and the content he searched in the body.

Hope you understood the question.

Thanking You, 5416339

+4  A: 

The question mark is not valid in a URL path; it is used to separate the path from the query string. You will need to detect the presence of a previous search and serve that content up yourself. Putting the search results in a file named after the search terms in a separate directory is a good idea though. See fopen(), fwrite(), fclose(), and readfile().

Ignacio Vazquez-Abrams
Thanks will look at this.Any better suggestion ?
5416339
The file I/O operations are probably the easy part. Creating the static file with fully-rendered output will be a little more complex, though not a terribly big deal with a decent template system. Probably just keep a standard search result template with a place to insert the content, open it, do a string place to insert the content, save as a new file.
David
And do this opening and creating a file each time they search will make my search results a little slow ? Because this has to happen simultaneously right ?
5416339
Unless the search is incredibly fast (probably on the order of tens of milliseconds or less), the file output will be only a very tiny fraction of the delay before the page comes up.
Ignacio Vazquez-Abrams
Ok,Then i think i run the Copying function at the footer.Why do you think ?
5416339
I would do it after you've sent everything to the client and flushed it.
Ignacio Vazquez-Abrams
Ok,Thank you for your support.See you around and ave a nice day !!
5416339
Beware of including files by referencing them directly by name in the URL. That could lead to hackers obtaining sensible files from your server. Name the files with a transformation of the string (like an MD5, for instance), and find them later by applying the same transformation again to the search string.
Sebastián Grignoli
It's more reliable to URL-encode the search phrase, since hashes do collide on occasion.
Ignacio Vazquez-Abrams