Ready to move from html - php site...how?

They have: 2 posts

Joined: Nov 2004

Hi all,

I have been designing small websites lately with old fashion html that and just started woking on a project that is going to be by far my biggest site to design and realize there has to be easier way than using html. I'm a little overwhelmed but ready for the challange. I remember reading somewhere in a forum about developing website using php with I beleive was global include commands? Saving time in site maintence, cutting down time in creating same graphics over and over just changing the content of each page? Is this along the same idea as old fashion frames where you use the same header, footer, navigational and just the content frame change? I have created my graphics for header, etc., but have no idea where to find tutorials on how to set up the correct commands for php files and how to set it up in html. Would you please recommend, tutorial, books etc, that is simple enough for someone who has no programming background at all! Someone suggested buying a program that can do it for me to save time however I am one of those who like to know how and why something works as well troubleshoot when a problem occurs. Plus I would feel a little guilty charging client for what was done in program and not actually by me. Call me old fashion LOL.

Thanks for any suggestions you can offer. Wink

CptAwesome's picture

He has: 370 posts

Joined: Dec 2004

Well, there are a lot of ways of going about learning php. What you can first try is the header/footer sort of nreaking your site up into parts, so you have to do less edits over the whole thing. Something like that is really simple. Just a few includes, and you're well on your way.

The best thing to do is get some old scripts from people. Because experienced programmers stuff will be gobbled gook and jibberish probably. You need to see the basics, and work your way up.

They have: 2 posts

Joined: Nov 2004

Thank you CptAwesome. That is exactly what I was hoping to accomplish...less time editing the site as whole. My next question is where to find such scripts or tutorials? I did a search on yahoo and wow...I think I'll save time and the headache of going from site to site and purchase a php tutorial book. LOL
Thanks again.

CptAwesome's picture

He has: 370 posts

Joined: Dec 2004

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

The book I read to learn php and MySQL was "PHP AND MySQL" by Larry Ullman. Lots of coding examples and easy to learn from.

They have: 26 posts

Joined: Apr 2005

Ok, here's the deal. If you follow these instructions you will make your first php linked site. Its pretty easy, and I have made this selection of pages very simple.

Create a page called index.php and put the following into it:

Untitled

 

<?php
include 'title';
?>

<?php
include 'contents';
?>

<?php
include 'main';
?>

Now create a page called view.php and put the following into it (this is exactly the same as the index page only with a change to the php code in one of the cells):

Untitled

 

<?php
include 'title';
?>

<?php
include 'contents';
?>

<?php
$page
= $_REQUEST['page']; include("$page");
?>

You now want to create 5 files - title, main, hello, goodbye, contents. Note (using 'title' as an example - Please dont name it title.html or title.txt - just name it 'title'

In title write Title
In main write My starting page
In hello write Hello
In goodbye write Goodbye

And finally in contents write the following:

Index
Hello
Goodbye

Please be aware that there is no need for any html body tags or anything in any page other than index.php and view.php.

Thats it I think. Now upload the lot to a server, and have a look at index.php. Clicking on the link in the contents section will load the appropriate page in the main section, replacing what was previously there. If you want to make a new page, just add a new one in the style of the 'hello' or 'goodbye' page, and make a link to view.php?page= with whatever you call the page after the page=.

The title and contents will appear on every page you view, so if you change that contents/title page, it will change it on every page on your site automatically.

I hope this helps. If by chance this doesn't work, tell me - I'll have a look at it for you.

You can see an example of a site using this method at http://www.heartsaffection.com

Cheers,

Andy

They have: 26 posts

Joined: Apr 2005

Oh, I forgot to mention, changing your current site to php should be pretty easy. Just have a look at your front page, and decide what sections you want to break it down into. http://www.heartsaffection.com for example is broken into a header, footer, main text and right hand contents column sections.

In your index.html page, just cut out the sections and save them in new files. Replace the empty space in the index file with

<?php
include 'title';
?>
swapping title for whatever it is that you have called the new file.

Busy's picture

He has: 6,151 posts

Joined: May 2001

If you or anyone buys any PHP books, make sure the book includes PHP5 as there is a lot of new functions that 3 and 4 didnt have.

Also do a search on these forums for PHP help and databases and learning php and mysql for more great advice

Welcome to your new addiction muhahaha Laughing out loud

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Indeed Busy is correct, the way PHP handles object orientation has been completely re-written... Programming PHP is somewhat different in Version 5, although most hosts have not upgraded yet, perhaps it would be a good time to start complaining Smiling

a Padded Cell our articles site!

They have: 26 posts

Joined: Apr 2005

Oh, I forgot to mention, and it is slightly off topic, however if you were going to swap over to php you can make other little bits and bobs easy too. Replace you 'Copyright 2005, All Rights Reserved' comment in your footer with 'Copyright

<?php
echo date("Y"); php
?>
, All Rights Reserved'. If you file is saved as a php file, this will save you ever needing to update your copyright to the current year. Ok, so I guess that just shows how lazy I am, but its little things like that that can make your life much easier.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.