Page 1 of 1

newbie - writing a file

Posted: Tue Aug 05, 2008 8:56 pm
by kippy
How can you write php code and html code into a newly created file all using php script? When I attempt to place the html and php code in the variable to write to the new file, the script has problems writing the new infor to the file. I think it has something to do with the quote marks within the content I am trying to write. Any help is appreciated.

Re: newbie - writing a file

Posted: Tue Aug 05, 2008 11:59 pm
by Ambush Commander
It would be helpful if you posted the code you were running, but it sounds like you've either got a permissions problem or a flat out invalid filename. Also, why are you generating PHP with PHP?

Re: newbie - writing a file

Posted: Wed Aug 06, 2008 1:17 am
by RobertGonzalez

Re: newbie - writing a file

Posted: Wed Aug 06, 2008 2:16 pm
by kippy
Well basically what I want to do is when someone registers on my site I want a new directory to be created and inside that directory I want a new index file to be created and inside this new file there will php. So basically I have to use php to create a brand new page that contains html and php in it. I hope that makes sense.

Re: newbie - writing a file

Posted: Wed Aug 06, 2008 2:46 pm
by RobertGonzalez
You may want to rethink your structure here. You could easily handle this with a single bootstrap file, a database and some url rewriting.

Re: newbie - writing a file

Posted: Wed Aug 06, 2008 2:48 pm
by Ambush Commander
Indeed. What happens if you need to update the PHP code?

Re: newbie - writing a file

Posted: Thu Aug 07, 2008 1:45 pm
by kippy
Mr. Modnificent can you give me an idea on how you would handle it? I am not familiar with a bootstrap file, etc. Thanks.

Re: newbie - writing a file

Posted: Thu Aug 07, 2008 4:02 pm
by RobertGonzalez
Basically all you need is one file that handles data fetches for a user based on the user name or something like that. So instead of having /user1 /user2 you would need like /index.php which would take a query string var of say userid (like /index.php?u=<userid>) where <userid> is a number of the user.

Re: newbie - writing a file

Posted: Sat Aug 09, 2008 5:58 pm
by kippy
I was planning to create a new directory for each registration...inside these directories would be the index.php that could display that users information etc. How can I generate a new directory with the same dynamic index file included? Thanks.

Re: newbie - writing a file

Posted: Sat Aug 09, 2008 11:00 pm
by RobertGonzalez
You would make the index page (the bootstrap) handle the request for the users information. Rather than building 500,000 identical pages (yes, I think big) you build one page that fetches the information for that user the way you want to fetch it.

Re: newbie - writing a file

Posted: Thu Aug 14, 2008 6:09 pm
by kippy
I was planning to use seperate directories so the user would have a url to remember and be specific to them...almost a mydomain.com/users/name they define...is that possible?

Re: newbie - writing a file

Posted: Thu Aug 14, 2008 11:17 pm
by RobertGonzalez
That is more than possible. One file, everything for a user pushed through it by username. Super simple concept. Think mod_rewrite.

Re: newbie - writing a file

Posted: Fri Aug 15, 2008 4:43 pm
by kippy
Thanks, I will see what I can do...