Page 1 of 1
Dynamically creating URLS based on user input !
Posted: Tue Mar 13, 2007 10:32 am
by lunny
Hi,
I am looking to create pages on the fly or dynamically based on user input. For example if i have
http://www.example.com and they visit this and enter 'bob' in a textfield and press submit they create
http://www.example.com/bob.html . How would I go about this ? I am guessing I need to create a folder when submit is pressed in my website directory ?
Posted: Tue Mar 13, 2007 10:36 am
by feyd
Avoid dynamically generating files. Aim for dynamically filling their request for the files. mod_rewrite can be used for this.
Posted: Tue Mar 13, 2007 10:59 am
by lunny
ah yes will read about mod-rewrite
But lets just say to ease my mind how would i dynamically create URLs ?
Posted: Tue Mar 13, 2007 11:54 am
by lunny
Everah | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
When i try to do the following
Code: Select all
$filename = '.../public_html/newFile.php ';
$mytext = 'text';
fopen($filename, 'w+');
fwrite($filename, $mytext);
fclose($filename);
..
i get
Warning: fopen(../public_html/newFile.php ) [function.fopen]: failed to open stream: Permission denied in /public_html/test.php on line 19
Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/test.php on line 20
Warning: fclose(): supplied argument is not a valid stream resource in /public_html/test.php on line 21
How do I solve these problems with my permission
Everah | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Tue Mar 13, 2007 12:17 pm
by PapiSolo
I'm no Guru, but that doesn't seem like a PHP problem.
I would check to see if the user running apache (usually "apache") has permission to write to the folder public_html. That could be the problem.
Posted: Tue Mar 13, 2007 5:40 pm
by RobertGonzalez
You are probably going to have to open that directory by assigning it a permission of 666 or even 777. Either way, having writable directories on your server is insanely dangerous if your are not careful of what is going to be written to it.
Posted: Tue Mar 13, 2007 6:30 pm
by s.dot
fopen($filename, 'w+');
the 'w+' should be "w+" (double quotes)
Posted: Tue Mar 13, 2007 11:32 pm
by feyd
scottayy wrote:fopen($filename, 'w+');
the 'w+' should be "w+" (double quotes)
They both result in the same string last I checked.
Posted: Wed Mar 14, 2007 5:05 am
by PapiSolo
Everah wrote:You are probably going to have to open that directory by assigning it a permission of 666 or even 777. Either way, having writable directories on your server is insanely dangerous if your are not careful of what is going to be written to it.
Please correct me if I'm wrong, but I don't think that he needs to open the directory that much. If owner is apache and group is root (for example...) then 664 or 774 will suffice and that would be a bit more secure.
Posted: Wed Mar 14, 2007 10:55 am
by RobertGonzalez
I think you are right. But I have a thing with not opening up directories for writing from unknown sources. That is just me.
Posted: Wed Mar 14, 2007 2:43 pm
by Kieran Huggins
for some reason when creating a new file to write to, PHP often suffers from this error. The solution in at least 30% of the cases I've come across it to touch(the.file) first - then everything works as advertised.