views:

142

answers:

2

Well,my current situation is like this.

When i search something on my site for ex. http://example.org/web-search.phtml?search=SEARCHED+TEXT the respective content is shown.

As you can see I'm using a GET form to get the data from the previous form.So the first thing i want to do is open a file with the same as SEARCHED+TEXT.So now i want to open and save file in

http://example.org/web-search/SEARCHED+TEXT.html

So each time a person searches a page like http://example.org/web-search.phtml?search=SEARCHED+TEXT a respective .html file should be created in the respective folder

And no.2

Now i want the whole source of http://example.org/web-search.phtml?search=SEARCHED+TEXT to be copied into http://example.org/web-search/SEARCHED+TEXT.html

So how do i do this ?

NOTE: If i copy the whole source including the code for copying and creating file then each time the person creates http://example.org/web-search/SEARCHED+TEXT.html a new HTML file will be Opened..

So i hope you got my BIG BIG question !!

I'm not saving the results.I'm just saving the iframe source.So technically its not static

+1  A: 

You can use file_put_contents() and the $_GET to do the operations you want.

Firstly you can get the filename of the file by calling :

$filename = $_GET['search'] . '.html';

That would return your value, SEARCHED+TEXT

Secondly you can use file_put_contents($filename, $some_source_content) to create the file.

etbal
"file_put_contents($filename, $some_source_content)"
5416339
make this "$some_source_content" ?
5416339
be careful with this. Make sure you sanitize $filename else some one can do something like: http://searchr.us/web-search.phtml?search=%2Fproc%2Fsys%2Fkernel%2Fcore_pattern which would write to some core files.
MANCHUCK
But i have remove HTML tags !!
5416339
is my site vulnerable to it ? http://searchr.us/web-search.phtml?search=%2Fproc%2Fsys%2Fkernel%2Fcore_pattern
5416339
@5416339 To be rude, fuck yes it is. You need to fix that [before you put it online](http://www.reddit.com/r/programming/comments/dqms6/european_union_should_pay_real_contractors_to/). MANCHUCK already linked you to one resource for input sanitization. Never trust user input, your website will get hacked, worse than you think.
A: 

What i think you want to do is use apache mod_rewrite, you point anything from /web-search/(.*).html to some php file on your server (search.php) and use that PHP file to render all of your searches. This will give you the dynamics you want without creating a billion flat files on your server for no good reason.

gwagner
Misunderstood the question. He already has a dynamic solution. `http://searchr.us/web-search.phtml?search=SEARCHED+TEXT`. What he's looking for is a way to cache the results of the dynamic solution.
steven_desu