Sorry if this may seem silly, but I decided to learn some more php and mysql by working on a personal project, which will start small and grow into what I want it to be.
The final product should be a website with a user log in, articles page, profile page, image gallery, user specific image gallery. I’m reading a book and it got me a little confused by using index.php as a controller, which based on a $_GET shows a different page… After looking into it more is when I got confused. Coming across MVC got me even more lost, although the concept seems nice, its just more than I can digest right now.
Right now, I’ve ended up with:
/articles/index.php - will act as controller and call a page where a user can submit something, or call a page where the user can view the articles (default if no _$GET is sent), the view page will also control and send the user to a different page if a user clicks on a specific category or article and send them to a page accordingly.
/member/index.php will take a person to a member list or something, if ?id= is specified will take them to someones profile… if its a logged in user looking at their own profile there will be an edit button or soemthing which will take that user to the edit profile page (thru index.php).
in root there will be an index.php sending people to main.php by default, about, contact, login based on $_GET.
/handlers/ will house the various user submitted forms and db connection…
Am I anywhere near the right track? Or should I just go jump off a bridge, 'cause I’m just NOT getting it.
It sounds like you need to concentrate on small pieces of the project first. Learn how a basic PHP contact form works first. Get a book on basics of PHP. In my opinion what you are reading is just too much to digest at one time.
I know how forms work… I also know there are many ways to structure a website, I was just wondering if there is a “terrible” way to do it, so that I make sure not to do it that way. No matter which way I set it up it “works”, but I want to make sure I’m able to build on top of it as time goes on, rather than learn the hard way by getting “there” and then having to rehaul the whole project.
A home page should also provide an sitemap or table of contents and guide visitors to the information they need. If they can find the information they want quickly and easily, they will enjoy their visit. And if they enjoy their visit and find that the time spent there was worthwhile, they’ll come back.
You could create multiple index.php files like you have there, but it’s not really a common set up. The drawback is that if you ever decide you want another “module”, you need to first create a directory, put an index.php in it, bootstrap the index.php, etc. What you will find is that all the index.php files are very much (if not completely, except for a few path parameters) the same.
Normally one would just create one index.php in the public_html/ (or the equivalent thereof – different hosts use different names) and route everything through that one index.php with .htaccess
The advantage of that method is that all directories are basically fake; they don’t really exists. They only exists because index.php can read the URL and do something useful with it.
As for the db configuration et al, it’s better to put in a directory outside the public_html/ directory (if you have write access there) for better security.