Alright, so I built my site completely using html and css. I am finding that as I'm updating it along the way it is becoming rather laboursome to have to go to every single .html page to modify the header and footer code just so it will function the same. I know you can simplify this using php so you only have to modify the one file and it will automatically update for every page. So I guess my question is how do I go about doing that?
So let's say my I change my index.html to index.php. I copy all of my header code and paste it into a header.php file and then add this code to the top of every page?
<?php include 'header.php'; ?>
Will the header code then look something like this?
What do you mean by "preview"? Are you trying to open them in a browser on your local machine? Are they on your live website? Do you have PHP installed?
I am trying to open them in my browser on my local machine. That is how I have been viewing my .html pages so far as my site isn't completely live yet.
Yeah, if you're trying to open them up locally, it won't work. You would need to download Wamp (Windows) or Mamp (Mac). If you upload to a live server, it should work.
Alright, MAMP is working properly, but I'm having a problem. I changed my index.html to index.php and placed it in the mamp/htdocs folder. I tested to see if it worked by placing random text into the index.php file and it appeared in the browser so Woot! But when I paste my html code that I had before the page remains completely blank. Not even any < p >text< /p > is showing up. I'm not sure what I should do from here
I don't believe I put anything for the root password. I tried adding the php code to the beginning and end of my html and when I refreshed my web page I got a server error instead of a blank white page
Alright, I finished the tutorial but it turns out, that wasn't the answer to my problem. It was directly related to my header code. If I had listened to your advice in the beginning and changed it to the doc type to html5, I'm sure I wouldn't be having this problem. Here is the code I had to delete to make my page run smoothly.
<?xml version="1.0" encoding="UTF-8"?>
Thanks for all your help. I'll post back if I'm having any other issues but it looks like it should be smooth sailing from here. Cheers!
How can I include header & footer if my content page is inside sub folder. Could you plz tell me what script i've to use if my pages inside folder / sub folder. so far i know and see here:
<?php include 'header.php'; ?>
if my pages without folder.
You need to change your file extensions to .php
So the end result would look like this:
Will the header code then look something like this?
I tried experimenting with that and it won't let me preview the index.php file (probably because it's not a webpage)
I also noticed your title. You're going to need a loop to determine the title of the page.
and then to include it for every page, just paste this in your index file(s)
http://css-tricks.com/video-screencasts/86-mamp/
Also, just for kicks, try adding this before the HTML (at the very top of the page)and thenafter the html
What error did it display?
http://i50.tinypic.com/zybja0.png
Are you also putting the files you're working on inside htdocs?
Not Found
The requested URL /phpinfo.php was not found on this server.
Thanks for all your help. I'll post back if I'm having any other issues but it looks like it should be smooth sailing from here. Cheers!
How can I include header & footer if my content page is inside sub folder. Could you plz tell me what script i've to use if my pages inside folder / sub folder. so far i know and see here: <?php include 'header.php'; ?> if my pages without folder.
You can go inside subfolders with
include 'subfolder/header.php'or inside parent folder withinclude '../header.php'