newbie - writing a file
Moderator: General Moderators
newbie - writing a file
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.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: newbie - writing a file
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?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: newbie - writing a file
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: newbie - writing a file
You may want to rethink your structure here. You could easily handle this with a single bootstrap file, a database and some url rewriting.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: newbie - writing a file
Indeed. What happens if you need to update the PHP code?
Re: newbie - writing a file
Mr. Modnificent can you give me an idea on how you would handle it? I am not familiar with a bootstrap file, etc. Thanks.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: newbie - writing a file
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
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: newbie - writing a file
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
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?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: newbie - writing a file
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
Thanks, I will see what I can do...