I am attempting to create a website utilizing PHP as the driving power behind the gears. The idea behind the site (generally) requires that each user be presented with the option of creating their own profile (currently considering creating a directory for each user).
I have been doing considerable research in order to set this application up in the best means possible. But I am suffering from extreme confusion when it comes to creating the directory structure. I am considering downloading a framework assistant (CodeIgniter) which might assist me in the venture, but I’d rather get the opinions of others first.
Currently I have all of my files and content within my public_html folder, and I am aware that this is not the ideal set-up. But I’m not sure how to go about creating an alternative structure. I do not know where to store the various templates (header.php, footer.php, etc) and how/where to call them.
I want to create pages to list the “About”, “Contact Page”, and other content, but do not know where these pages should be located? Do I save the content of these pages within the public_html directory and simply include the templates from the various subfolders?
Concerning a config.php file: I am attempting to have all of the necessary information pertaining to MySQL connections within a single file, as well as other necessary information to be included at the beginning of EACH page within the site.
Thoughts? I’m fairly new to the cloud, and so simple and basic responses would be greatly appreciated!
You’re thinking of this wrong. You don’t need a directory for each user. You can use GET params to have one script (profile.php, for example) pull the appropriate profile for a user dependent on data passed to it. For example,
profile.php?userid=5212would pull the profile for user5212($_GET['userid']would contain the user’s id in this case). Passing nothing could easily default to pulling the profile for the currently logged in user.You could also use
mod_rewriteso thathttp://www.yoursitehere.com/profile/5212/could do the same thing (look into routes in most PHP frameworks)Your directory structure should suit you. If the site is simple enough you could get away with something simple like just
Your database configuration could live in
public_html/includes/and you could include it on any page requiring a database connection. Your about and contact pages can be actual files located inpublic_html/to keep things simple. Again, these are just suggestions. Your directory structure should be whatever you need it to be.