Help w/ PHP

Hey, I’m an amateur webmaster. Can anyone give some advice with implementing PHP and MySQL with the following website:

There are two easy things you can do to that page using PHP:

Right now, you are calling separate HTML files inside of a frame in order to create sub-pages. Instead of that, you could just write up your page template as separate file and simply have PHP automatically stick that header and footer into every single one of your pages. Then each individual page’s code will look like:

<p>Oh man, what a cool page I have!</p>

Header.php and footer.php will contain all the boring HTML markup that is the same on every page, freeing up each file to just be the relevant code for that area. You can google around a bit to find some more information on these techniques, and I highly recommend taking advantage of the website, which lets you search for information about almost anything you would ever want to know about PHP commands and syntax.

If you get comfortable with that, you can get really fancy and build a membership system. This tutorial is what taught me how to create login systems that I have since used on a few of my own projects. It’s extremely step by step, but by the end you should have a solid understanding of what each piece of the system is doing when a user logs in.

You could use a user login system to protect sensitive documents, set up some sort of communication system, or just to be cool-looking.

Good luck! PHP is some pretty amazing stuff.

Is there something specific you want to do? If so I can help you. What where you planning on using MySQL for?

The suggestion about include statements is definitely a good start, but once you get comfortable with that, you might want to move into storing content for each page in a database, then use a PHP to print the page’s content from the database rather than from each file. That way you have ONE page with all of the relevent header and footer for every page, and the database holds unique entries for each of the others. It also saves a lot of space and effort. If you decide to add another section in addition to header/footer (or whatever you have) you can easily go back and change it once, rather than have to add it to every file again, which was the idea to avoid in the first place.

Another option if you have a lot of pages: you can create the basic layout page (the header and the footer) and replace the body content with this code:

if($_GET'page'] == "") {
} else if (!file_exists("includes/".$_GET'page'].".php")) {
	echo "Page not found.";
} else {

This code just checks that a body content file exists and then loads it. Navigation is done by index.php?page=home. If no extenstion is given, then it loads main.php.

It’s simple and I’ve seen a lot of websites use this method.

That’s probably a better idea than I suggested. I guess I just overthought it. I’ve used that method, too, and it is certainly simple enough to pull off.