Jump to content


Photo

Php Minitutorial 1


  • Please log in to reply
62 replies to this topic

#1 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 01:16 PM

I have no idea if this is even something that others want to read... so here goes:

Let's cover three things:

1-What php can do for you
2-Your first php page
3-Putting the time and date on your page

PHP is a server side code, which means that before your visitor ever sees a thing on your site, the server is told to perform some functions and first. For example, you might tell the server "Get today's date, put in a certain format, and show it in this table... then send the html to the visitor."

The great thing about php is that except for the fact that the page ends with .php, all they see is html if they view the source code. There are even ways around the .php ending... but we're not covering that.

In contrast, JavaScript is a client side code. Your visitor has to have Javascript turned on and installed in order for all the neat javascript to work on your website. The good news is that most people have javascript enabled on their browsers.

So, where PHP would get the time and date from the server, you could have a similar javascript program that gets the time and date from the visitor's own computer.

Both codes have pluses and minuses... but the fact that php works on everyone's computer (since it does all the magic at the server) I've focused my efforts on PHP.

There are other differences between javascript and PHP, but that's not the issue right now.

So why use PHP?

Rather than give you an infinite number of uses for PHP, here's a shorter list of ways that I've used it to help improve my websites:
  • Storing user inputs, passwords, and so forth in a database
  • Dynamically generating thousands of pages from a database
  • Processing forms and sending out mail to users
  • Dynamically 'including' snippets of HTML for pieces of my website you see on every page (NAV bar, copyright, logo, etc.)
  • Updating thousands of pages and changing the entire look of a website by modifying just two files
  • Automatically generating meta tags for Title, Description, etc.
  • Putting the date on my pages
  • Generating pdf (Adobe Acrobat) files from user input
  • Password protecting pages
  • Pulling news and other information from other sites and having it update automatically
And that's the short list.

The good news is that PHP is pretty easy to learn.

#2 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 01:28 PM

Creating your first PHP page.

Step one: open up one of your html files in your html editor of choice.
Step two: save it as the same name but end it in .php instead of .htm or .html

Done.

You see, any html file can be named .php and it will still work just like it did before... assuming your hosting company has php (which TCH most assuredly does).

Now, renaming all your files .php is not only unnecessary, it's not very useful.

So let's create a simple php script and see what it does:

<?php
print("Hello World");
?>


You can paste this into your text editor, name it as test.php (or anything.php) and ftp it to your website. You'll see it says "Hello World" when you load it up in your browser.

Line by line:
<?php tells the server "starting php code here"
print("Hello World"); tells the server to print Hello World

Notice that the line ends with a semicolon ;

Every line of php code must end with a semicolon. Some lines of php code can wrap to the next line so I guess it's more accurate to say that every php line of instruction must end with a semicolon. (This doesn't count comments added to the end of a line)

?> Tells the server "Done with php code here"

Next... mixing php code and html together

#3 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 01:44 PM

Mixing html and php together is easy.

You just have to tell the server where php starts and where it ends.

Let's look at something just a tiny bit more involved:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$name = "Psycho Bob";
?>
<p>My name is <?php print("$name"); ?></p>

</body>
</html>

You can name this whatever.php and ftp it to your site. It will dutifully print out

My name is Psycho Bob


First, notice that even though it's a php file, it starts out as pure html... no problem.
Then php kicks in with <?php
The line

$name = "Psycho Bob";

assigns value Psycho Bob to the variable $name

Then we have a regular <p> element that starts off as normal html.

Then right in the middle of everything, we break back into php, tell the server to print the value of $name, and break back out of php and into html.

Pretty slick!

#4 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 01:54 PM

Putting the date and time on your webpage:

Okay... you've made it this far...

Let's do something actually useful.

Anywhere in your php file that you want to add the date, you can put

<?php echo date("M d, Y") ?>


There are many ways to format the date and time... entire tutorials have been written on it. For now, if you've made it this far, take a much needed break... congratulate yourself.

But if you're yearning for more php know how then check out these links:
DevShed::PHP
PHP Builder

Depending on the response from these posts... I'll add more in a few days.

(Or I'll actually get some work done on my own stuff) ;)

#5 natimage

natimage

    February Family member of the month

  • Members
  • PipPipPipPip
  • 824 posts

Posted 19 May 2003 - 04:00 PM

Hello...it's great to see others putting time and effort into adding posts such as this one. I am just starting to learn php, but for some reason I am just not grasping it. I've made it past understanding the tasks you've tackled in the previous posts...however, when it comes to sitting down and planning how I'm going to set up the site...the buttons...the tables and whatever else...I realize that I may understand the concept, but have no idea of the steps I need to follow to actually apply it to a site.

In short...why do people always say that after they've been really long-winded???...
anyway...in short...I'd love to see more posts. Especially any that revolve around the "process" you have to take to make a site work.

Have a good day,
Tracy
Tracy
Natural Images Photography


<A HREF="ymsgr:sendIM?natimage72"><IMG SRC="http://www.tchstatus.com:8080/yahoo/natimage72"></a>

#6 chadf

chadf

    Family Friend

  • Members
  • PipPip
  • 56 posts

Posted 19 May 2003 - 04:52 PM

Thanks for the informative posts. I'm relatively new to the web design world - especially the server side - so I'm always ready to learn something new. Please keep it coming.

- Chad

#7 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 05:11 PM

Alright then... let's tackle some of those issues you mentioned, Tracy.

First of all, most PHP pages are nothing more than html pages with some extra code thrown in. Some are pure php code... but you can get a ton of use out of php without knowing a whole lot of it.

If you look at the php written by other folks, you'll see two distinctive styles:
1- HTML dominant with php spliced in
2- PHP dominant with html spliced in

For whatever reason, option 1 makes the most sense to me.

What I do, is basically create an html page... and get it to where I want it to be in terms of layout... and then I stop.

Let's say I save this as template1.htm

Notice I saved it as html... there's no php in there... and there never will be... this is going to be my template.

How, I'm going to show you something really cool. In my opinion, this is the coolest thing PHP can do... and the easiest.

What we're going to do is break the page up into three pieces
1-Header
2-Main body
3-Footer

The main body will change from page to page. But for most sites, the header and footer will stay the same. This is where the nav bar, logos, and copyright information usually goes.

What I'm going to show you will save you countless hours of tedious programming and typing.

Let me create a fake template1.htm:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
† <tr>
† † <td width="25%">
<p>Logo goes here</p>
† † † <p>&nbsp;</p></td>
† † <td width="15">&nbsp;</td>
† † <td><div align="right">Date here</div></td>
† </tr>
† <tr bgcolor="#FFFFCC">
† † <td>&nbsp;</td>
† † <td>&nbsp;</td>
† † <td>&nbsp;</td>
† </tr>
† <tr>
† † <td valign="top" bgcolor="#FFFFCC">
† † † <table width="100%" border="0" cellspacing="0" cellpadding="0">
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link One</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Two</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Three</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Four</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center"></div></td>
† † † † </tr>
† † † </table>
† † </td>
† † <td>&nbsp;</td>
† † <td valign="top"><p>Main Body Here</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p>
† † † <p>&nbsp;</p></td>
† </tr>
† <tr>
† † <td colspan="3"><div align="center">Copyright 2003 Jim Bob Productions</div></td>
† </tr>
</table>
</body>
</html>

Wow... that's an ugly webpage... but it'll work for illustration purposes.

See where it says "Main Body Here" in the code?

Everything before the opening <p> next to Main all the way up to the top of our html document is going to be copied and pasted into a php file.

Let's call it header.php (original... I know)

header.php will look like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
† <tr>
† † <td width="25%">
<p>Logo goes here</p>
† † † <p>&nbsp;</p></td>
† † <td width="15">&nbsp;</td>
† † <td><div align="right">Date here</div></td>
† </tr>
† <tr bgcolor="#FFFFCC">
† † <td>&nbsp;</td>
† † <td>&nbsp;</td>
† † <td>&nbsp;</td>
† </tr>
† <tr>
† † <td valign="top" bgcolor="#FFFFCC">
† † † <table width="100%" border="0" cellspacing="0" cellpadding="0">
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link One</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Two</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Three</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center">Link Four</div></td>
† † † † </tr>
† † † † <tr>
† † † † † <td bgcolor="#FFFFCC">
<div align="center"></div></td>
† † † † </tr>
† † † </table>
† † </td>
† † <td>&nbsp;</td>
† † <td valign="top">


Similarly, everything after the closing </td> at the end of "Main Body Here" all the way to the end of the document goes into a new php file we'll call footer.php.

footer.php will look like:

</td>
† </tr>
† <tr>
† † <td colspan="3"><div align="center">Copyright 2003 Jim Bob Productions</div></td>
† </tr>
</table>
</body>
</html>

I left out all the carriage returns because that's stuff that will be replaced by real content in a moment.
One last step and you're on your way to creating umpteen bazillion webpages.

We create a new webpage we'll call template.php. Notice that this is a php file.

It's going to look exactly like this:

<?php
include $_SERVER['DOCUMENT_ROOT']."/inc/header.php";
?>
<p>Main Body Goes Here</p>
<?php
include $_SERVER['DOCUMENT_ROOT']."/inc/footer.php";
?>


So what does this do???

It tells the server, "Start in the root of the site (www.yoursite.com) and look in the folder named "inc" (which is where you are going to put these php files) and get everything in the header file and include it at the top."

Then we switch over to html for a second.

And then we tell theserver, "Start in the root of the site (www.yoursite.com) and look in the folder named "inc" (which is where you are going to put these php files) and get everything in the footer file and include it at the bottom."

Once we have template.php, we ftp our files to the server. We create a new folder called "inc" for our header.php and footer.php to live in. Then we test it out.

Assuming it works... and why wouldn't it?... we now have a template for all of our other webpages. Not only that... when you view the source code from your browser... it's perfectly formatted html... because the php did it's magic before showing you the webpage.

So for my home page... I open up template.php in my html editor (Dreamweaver or whatever) and save it as index.php (must be php). I then replace "Main Body Goes Here" with the real content for the page...

And we're done.

So now... anytime you want to add a link to your navbar, update your logo, or change the layout completely... you change these two files... and you've got a whole new website in an instant!

Enjoy!

Edited by surefire, 19 May 2003 - 05:23 PM.


#8 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 05:19 PM

Ooops... forgot to add our php date function to our handy dandy template.

Open up that header.php file.

Here's what it should look like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%">
<p>Logo goes here</p>
      <p>&nbsp;</p></td>
    <td width="15">&nbsp;</td>
    <td><div align="right">Date here</div></td>
  </tr>
  <tr bgcolor="#FFFFCC">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFCC">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link One</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Two</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Three</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Four</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center"></div></td>
        </tr>
      </table>
    </td>
    <td>&nbsp;</td>
    <td valign="top">


See where it says "Date Here"...? All we have to do is replace that with our php date function I showed you ealier...

<?php echo date("M d, Y") ?>

So now header.php looks like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%">
<p>Logo goes here</p>
      <p>&nbsp;</p></td>
    <td width="15">&nbsp;</td>
    <td><div align="right">
<?php echo date("M d, Y") ?>
</div></td>
  </tr>
  <tr bgcolor="#FFFFCC">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFCC">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link One</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Two</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Three</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center">Link Four</div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
<div align="center"></div></td>
        </tr>
      </table>
    </td>
    <td>&nbsp;</td>
    <td valign="top">


Voila... now every page on your site has the date at the top of the page...

And it matters not whether your visitor has javascript, flash, or whatever else loaded on their computer.

Pleasant coding.

#9 natimage

natimage

    February Family member of the month

  • Members
  • PipPipPipPip
  • 824 posts

Posted 19 May 2003 - 07:20 PM

Hi Jack...thanks for the extra info. I have a question, though. I may just be showing my lack of understanding for all the php benefits, but here goes...

The previous post shows how to build a template using php. What are the benefits to this over building a one file template using Dreamweaver (with or without embedded php)?

Here's one of my more specific questions for ya! I want to use drop down menus that list choices for the user and when these choices are submitted, I want certain information pulled from the database into a new form. I know this is really basic...but I just can't get the steps clear in my head. Can you maybe guide me in the right direction to at least get the page started? I usually catch on to things pretty quickly, but applying this php has really evaded me.

Thanks for the time,
Tracy ;)
Tracy
Natural Images Photography


<A HREF="ymsgr:sendIM?natimage72"><IMG SRC="http://www.tchstatus.com:8080/yahoo/natimage72"></a>

#10 Lianna

Lianna

    Immediate Family

  • Members
  • PipPipPipPip
  • 2,384 posts

Posted 19 May 2003 - 08:06 PM

Keep 'em comin' Jack! This is terrific and exactly what we like to see on the forums. We hope that all family members can contribute from their area of specialty and learn from others.

Rock!

#11 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 May 2003 - 10:23 PM

Tracy,

Good questions. I'll do my best to answer them.

The previous post shows how to build a template using php. What are the benefits to this over building a one file template using Dreamweaver (with or without embedded php)?

First, you can create the same effect I explained in detail using any server side language... ASP, SSI, Pearl, Python... although I have no idea how to do it.

I'm good at only one server side code: PHP.

Luckily it does just about everything you could want it to. (The community spirit you see at the TCH boards is very similar to the open source PHP community)

Back to your question.

My experience with Dreamweaver templates. Is that it's a software function that allows you to modify your entire site within Dreamweaver, then FTP the whole new site to your host.

And if that's incorrect... I apologize. I fooled around with Dreamweaver templates once a long time ago and never went back to it. On the other hand, when I learned about PHP includes, the light went off in my head and instantly I saw the potential.

I'll give you an example that should show you why I think PHP templates (no one really calls them that) is superior to Dreamweaver templates.

I have a website that's over 6,500 pages and growing. If I want to reorganize the NAV bar... add a link... or change the layout completely... I change two files... FTP those two files only... and the whole site is instantly changed.

If you can do that with Dreamweaver templates... that's great and you should use it.

Anything that saves you time and energy when it comes to updating your site is a positive in my book.

The day I find something better than PHP for the things I want to do... that's the day I switch. I'm not married to PHP.

Now... your second question:

Here's one of my more specific questions for ya! I want to use drop down menus that list choices for the user and when these choices are submitted, I want certain information pulled from the database into a new form. I know this is really basic...but I just can't get the steps clear in my head.


If by "menu" you mean "navbar" then you're probably talking about Javascript. The best way to do those nifty drop down navigation menus is with javascript. And there are plenty of ready made scripts that you can use for free.

But I think you mean, drop down selections in forms. Those select boxes. With PHP you can populate those drop down selection boxes with data fields from an array, a file, or even a database.

In a future tutorial, I might go over database connections and MySQL... but there are so many awesome tutorials written on this subject that I almost feel like I'd be helping others better by answering specific questions.

I think I wrote a script that is similar to what you are asking about. On one of my sites, there's a form where visitors can tell-a-friend. But this form's a little different:
  • The visitor sees a basic email message that will be sent to their friend from them
  • They choose how many friends they want to refer to me
  • The next form gives them only as many fields as they asked for
  • The form sends out emails to their friends
  • All of the emails are stored in my database in case I want to use them later (with great care and respect)
Your question is actually a little advanced... not hard... just ahead of this mini-tutorial. In general terms, your form is nothing more than plain-Jane html with a little PHP thrown in.

You use the include function to pull your database password in securely and privately, then you connect to the database, you tell MySQL what you want, then you create a loop that says "create more html tags and selection fields until there's no more data", and then the server sends the page to your visitor.

I know this doesn't tell you HOW to do it... but it's very possible and you can find more info on it at
Dev Shed:: PHP

Hope this helps.

In the next tutorial, I'll show you how to save yourself time and energy putting forms together.

#12 natimage

natimage

    February Family member of the month

  • Members
  • PipPipPipPip
  • 824 posts

Posted 22 May 2003 - 11:32 AM

Jack...I just wanted to tell you that the above post was the one that I somehow missed out on, and then couldn't remember what thread I had asked the question on. Thanks for the mental process...that will help some. I apologize for asking the same question twice.

Beyond that...I ordered my book last night. Hopefully it won't take long to get here. In the meantime...I'm going to work on the PHP template idea. I definately see the possibilities with that!

Tracy :D
Tracy
Natural Images Photography


<A HREF="ymsgr:sendIM?natimage72"><IMG SRC="http://www.tchstatus.com:8080/yahoo/natimage72"></a>

#13 fasttoon

fasttoon

    Family Friend

  • Members
  • PipPip
  • 30 posts

Posted 22 May 2003 - 06:33 PM

This is great stuff for a newbie like me.

Thanks.

#14 schmuck

schmuck

    Family Friend

  • Members
  • PipPip
  • 29 posts

Posted 25 May 2003 - 02:42 PM

Thanks for the tutorial, Surefire! :lol:

Let me ask a question which is perhaps very elementary. I'm self-learning HTML and XHTML right now, and I want to know if this PHP include function is aimed at replacing the frame function in HTML. You know, frames in HTML can cause a lot of troubles and is not recommended by W3C. Is PHP include a better option? Does it work exactly the same way as frames?

If it is, then what I should do is to add the script incorporating the header.php and footer.php in every page that I want to have the header and footer shown. Is that right?

Thanks for answering. :lol:

#15 SEO

SEO

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,370 posts

Posted 25 May 2003 - 04:43 PM

Schmuck:

You have a bit of a misunderstanding. Using the header and footer script as described here is just a means of repeating the same code throughout a series of pages without having to rewrite that code. It has nothing to do with frames, which is strictly HTML. For instance, you could put frames in a header, which could be in a php file.... make sense?

Frames can be a problem; I personally do not use them or recommend their use for many reasons (one, which is dear to my heart, would be regarding search engines).

#16 schmuck

schmuck

    Family Friend

  • Members
  • PipPip
  • 29 posts

Posted 25 May 2003 - 07:14 PM

Schmuck:

You have a bit of a misunderstanding. Using the header and footer script as described here is just a means of repeating the same code throughout a series of pages without having to rewrite that code. It has nothing to do with frames, which is strictly HTML. For instance, you could put frames in a header, which could be in a php file.... make sense?

dsdemmin, thanks for the clarification! :) I understand that technically speaking, frames in HTML means the browser displaying more than one webpage at the same time, while the PHP include function means repeating the same code in different webpages. I have a query here though. While technically the two things are different, their resulting visual effect can be similar: a website with a static header/footer/menu bar depending on how you configure it. This is actually what I thought when I asked the question, and that's why I said the two might be functional equivalents.

What I'm planning to do in my future website is to have a static header and footer. The header will be a banner with clickable links. The body/content section will display simple HTML pages, a phpBB forum or a Gallery. The footer will be standard copyright notice.

If I do it with plain HTML, I have to do through frames, which can be a bit troublesome. I am also not sure whether phpBB forum and Gallery can be properly displayed in the content section of a 800 pixels width size frame.

What if I do this through PHP? Is there any functional equivalent of frames in PHP where I can get this kind of "sectioning" done?

Thanks for answering! These questions are really simple I know, but to a newbie nothing is simple in programming :D

#17 SEO

SEO

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,370 posts

Posted 25 May 2003 - 08:23 PM

While technically the two things are different, their resulting visual effect can be similar: a website with a static header/footer/menu bar depending on how you configure it.

A little more clarification.... it is great that you are asking the questions you are, wanting to understand is over half the battle to understanding.

As you know, frames are used to break a window into regions, this can independently display their own content.

When you use php (or javascript, perl, etc.) to call a header script and/or footer script on a page, you are not displaying regions independently. It is just that the 'source' is coming from different places (i.e. files). The actual page is a single unit though (unlike frames). There is nothing in php which will 'give you frames'. Although that wording is funny, because you can use 'frames' in php filesÖ again, meaning that you put html in php files.


What I'm planning to do in my future website is to have a static header and footer. The header will be a banner with clickable links. The body/content section will display simple HTML pages, a phpBB forum or a Gallery. The footer will be standard copyright notice.


If the 'static' part of this statement is true, then you have to use frames. That is using 'static' as in remaining in the window as different information is being loaded. However, we can say the header and footer will be static information and thus put them in separate files and load them on all pages (as in the original example).

Again, I am not thrilled with frames. I am not sure why or if you need the header and footer to remain static on the window. As far as having things 'fit', you can do wonders with tables.

Not sure I helped... but you are asking good questions.

Food for thought: If you ever 'see' a site who's layout is one that is similar to what you want to accomplish, look at their source code and see how it was done.

#18 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 26 May 2003 - 10:59 AM

Schmuck:

You've phrased your questions in a way that's a little difficult to answer.

Strictly speaking, PHP and frames are nowhere close to the same thing.

However, my interpretation of what you're trying to do is something that PHP include() function will do very well. It will help you 'include' snippets of html that are totally repetitive across the entire site.

You have to realize that setting up your headers and footers with PHP include functions will create static html (as stated by dsdemmin) and will not create the frame effect that keeps a portion of your page fixed on the screen.

Dsdemmin is correct in that you should stay away from frames for a wide variety of reasons (especially SEO).

If any of this is confusing... here's a way to understand exactly what PHP can and can't do....

Try it.

The examples laid out here are short and simple.

Try them out and most of your questions will be answered.

#19 schmuck

schmuck

    Family Friend

  • Members
  • PipPip
  • 29 posts

Posted 26 May 2003 - 01:15 PM

Thanks dsdemmin and surefire for the explanations! :(

Now I'm pretty clear about the differences between PHP include and HTML frames. I guess what I should do right now is to finish my textbook on HTML/XHTML before asking further questions :P

Definitely I want to avoid frames. Actually PHP Include is a perfect option if I create all the pages and write their codes myself. The problem is what I want to "wrap" between the header and the footer includes phpBB forum and Gallery. I don't think I have the capability to amend the files of that two software to have the header and footer stay static. This is also the very reason why I've been trying to find a way, or a software like MT or Postnuke which I can have the forum and the picture gallery incorporated with less pain and effort (and thanks to surefire again for answering me on the other thread :) ). I know this is a rather big project. I'm just streching my potential to try to accomplish what seems to be quite impossible on the face.

Why I want to have the things integrated so much? Well I don't really know. It's kind of a personal feeling and I do want to have the various components of the website to look like integrated and not separate. Definitely, my task would be a hell lot easier if I just let the forum and gallery open in a new popup window. My friends indeed do not expect me to create a really good-looking website. All of us belong to another profession not computer programming. But I take this as a learning process and a challenge. :)

#20 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 26 May 2003 - 02:00 PM

You don't have to have the bulletin board 'wrap' and leave the header and footer static for the site to have an integrated feel.

Look at this page at TCH bulletin board. Despite the fact that you see the invision power board logo... there is an integrated feel to the site.

I am 99.9999% sure that this bulletin board script uses php include() function to put the headers and footers here.

If you want to create the same effect you see on this board... then use PHP include.

If you want the screen scrolling features of frames... then nothing, to my knowledge, will divide your screen into separate panels EXCEPT frames.

Unfortunately, frames has major drawbacks.

You mentioned you are thinking of postNuke. That works fine... but doesn't use frames either.

Like all options, Nuke and postNuke have strengths and weaknesses. Since I posted these in one of your other threads, I won't repeat it here.

It's as simple as this....

If you want the header and footer (or some other window of your page) to stay put while the user scrolls and navigates through your page, then FRAMES is what you are looking for.

As others have already said, there are "better" ways to give every page of your site a constant look and feel rather than frames.... but whatever works for you.

#21 criosa

criosa

    Family Friend

  • Members
  • PipPip
  • 53 posts

Posted 15 June 2003 - 09:05 PM

wow, very helpful. THANKS! :P

but I seem to be having issues...

I tried doing the template thing like you explained, and I get this for my header & footer:

Warning: main(/usr/local/apache/htdocs/header.php) [function.main]: failed to create stream: No such file or directory in /home/dancers/public_html/my-page.php on line 2

Warning: main() [function.main]: Failed opening '/usr/local/apache/htdocs/header.php' for inclusion (include_path='') in /home/dancers/public_html/my-page.php on line 2

(replacing header.php with footer of course. =))

I copy/pasted the "include" line, removing the inc directory, since I did not put them into a seperate directory - is that necessary?

any thoughts? tia.

~Christy

#22 natimage

natimage

    February Family member of the month

  • Members
  • PipPipPipPip
  • 824 posts

Posted 15 June 2003 - 09:29 PM

Hi, Christy.

Don't know if I can help or not...but I'll throw out a couple ideas. Make sure your file name in the script matches the file name you created. I know it sounds simple, but sometimes the simplest mistakes can cause us to go bald!!! :P

Make sure that you loaded the header and footer files in your public html directory. You do not have to put them into a separate folder...but if you ever get to using many of them for some reason, it will help with organization.

If the two things above check out, post your script for your main .php file so we can check it out.

Tracy
Tracy
Natural Images Photography


<A HREF="ymsgr:sendIM?natimage72"><IMG SRC="http://www.tchstatus.com:8080/yahoo/natimage72"></a>

#23 criosa

criosa

    Family Friend

  • Members
  • PipPip
  • 53 posts

Posted 15 June 2003 - 09:47 PM

hmm... this is odd.

I just uploaded it to my old host (where my domain is still pointing til I get the new version up or until my 2 "free" months run out), and it's working over there.

do you think the fact that I'm not using my domain name yet has anything to do with it? is so, maybe I'll have to make a temporary directory for people to visit the old version til I get everything running...

~Christy

#24 natimage

natimage

    February Family member of the month

  • Members
  • PipPipPipPip
  • 824 posts

Posted 15 June 2003 - 10:06 PM

Well...you're above my knowledge base on that one. But I would say that since it is working through your other host, you have it set up properly. If you don't get any more response on this thread, I would start a new one with your specific question regarding why it would work there and not on TCH.

Good Luck,
Tracy
Tracy
Natural Images Photography


<A HREF="ymsgr:sendIM?natimage72"><IMG SRC="http://www.tchstatus.com:8080/yahoo/natimage72"></a>

#25 criosa

criosa

    Family Friend

  • Members
  • PipPip
  • 53 posts

Posted 15 June 2003 - 10:25 PM

thanks Tracy!
I'll wait patiently to see if anyone else has a guess on this...

~Christy

#26 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 15 June 2003 - 10:42 PM

Hi Christy,
I just tried the template.php
I put it in a testphp folder, so I changed the include line to

include $_SERVER['DOCUMENT_ROOT']."/testphp/header.php";

And saved the template file as index.php and it ran ok
So I think if you have put the files in your public_html folder
it would be

include $_SERVER['DOCUMENT_ROOT']."/header.php";

is this what you have?

#27 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 16 June 2003 - 06:02 AM

And Christy, I would also mention that this code most likely will not work until your site moves over completely to TCH. Of course, you could try this at your other host if they have PHP.

But trying it at TCH before your site moves over will NOT work... in my experience.

#28 criosa

criosa

    Family Friend

  • Members
  • PipPip
  • 53 posts

Posted 16 June 2003 - 11:02 AM

Thanks guys!

On to moving everything over, I guess!

At least I know how to make updating simpler now!

~Christy

#29 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 24 November 2003 - 05:28 AM

Jack....

After reading this thread, I eagerly set out to test out how it would appear on My blank site unsuccessfully B) .....

header.php & footer.php were placed in folder root/inc/
index.php was placed in root/public_html/ & then in root/

why is it not showing up? Have I overlooked a step?

Kindest Regards

#30 TCH-Andy

TCH-Andy

    Immediate Family

  • Members
  • PipPipPipPip
  • 4,699 posts

Posted 24 November 2003 - 06:44 AM

deanavail

The index.php needs to be in the /public_html/ directory - not the root.

At the moment you have it in the root.

Andy
Andy Beckett
-----------------
Part of the TCH family since the beginnings of time.

#31 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 24 November 2003 - 08:16 AM

Thanks for responding...I tried that again, placing Index.php in root/Public.html/
As u can see it still no go??

#32 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 08 December 2003 - 04:36 PM

wow...could someone tell me what am I doing wrong..index/header/footer php would not come up

see the following links

index.php located under root
header.php located in root/inc/
footer.php located in root/inc

Kindest Regards

#33 MutualWisdom

MutualWisdom

    New To The Neighborhood

  • Members
  • Pip
  • 12 posts

Posted 08 December 2003 - 11:00 PM

This is a wonderful tutorial. I wish I found it before I wrote my newest template. I originally thought to use Java script to dynamically change the content section of my site.

I then learned that php can do it just as well and be searchable and often times more compatible than java.

Now, I have to turn my template that is all html tables and "rounder" graphics into the different php pages.

My issue is that I want to have a vertical nav bar in the left hand side of the page, under a static logo header, above the copyright footer, and NEXT to the changeable content area on the right.

Here's the template so far matthand.com

How do I create two different columns, the left menu bar, and the content area using php? I grasped how to make the header, body, footer in the tutorial.

Sorry for this newbie's ramblings...

#34 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 08 December 2003 - 11:45 PM

There is a nice article writter by Peter Levin
www.devarticles.com/c/a/PHP/The_Modular_Web_Page/

that shows how to take a template like yours and convert it to php modules.
It works vey well!

#35 MutualWisdom

MutualWisdom

    New To The Neighborhood

  • Members
  • Pip
  • 12 posts

Posted 09 December 2003 - 11:58 AM

Wow! Thanks for that article.

It brought up another question tho... My friends all prefer using <div> to organize their pages. I like using tables since I cannot figure out how to have 2 <div> display side by side unless I use table columns.

Do php includes work just as easy in a table as it does in a division?

Also, here's another article I found (after Don showed me that awesome resource)
http://www.devshed.c...P/Dynamic_Menu/

I think I want to use a dynamic menu bar with java script still but use the php includes to make it all fit on one page. Unless, is it possible to animate images to slide out with php like it is in javascript?

Thnx for the help thus far!

#36 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 09 December 2003 - 12:34 PM

Do php includes work just as easy in a table as it does in a division?

Yes. Anything you can do with HTML can be made easier with server side code. (PHP, CGI, SSI, Python, ASP, CFM, etc)

PHP is interpreted by the Apached server and executes instructions but sends html and other client side code to the browser. So there is nothing for the browser to interpret in PHP. Either your web host provides it or they don't. (TCH does, obviously)

Which brings up the next point:

is it possible to animate images to slide out with php like it is in javascript?


Not by itself, no. Animating images is something done either with javascript or layers, or both... but it's done client side based on movement of the mouse, clicking, or some other trigger (page loading, for example).

You can bring your javascript in from another file or have the javascript tags included in your html by the php. But by the time the digital info hits your browser, the server has already done whatever it's going to do with the php (or any other server side code).

A great use for PHP in menu bars is in setting classes or modifying your html code based on the url. This is an easy was to have the menu bar 'know' what page you are on so that some sort of marker gives the visitor a visible clue to help with navigation.

I can't tell you how amazing this little bit of knowledge is. Once you 'get it' you'll be able to create websites that almost 'think' for you and websites that you can update in seconds with new templates. Or even templates that can be applied by the visitor and remember on the next visit.

#37 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 09 December 2003 - 12:37 PM

By the way, I strongly advise anyone using php includes for web design to name their included files with a .php suffix. Do not use .inc

.php suffix is a great way to hide code that you don't want others to see. (but it's not perfect... nothing is.)

#38 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 09 December 2003 - 04:50 PM

wow...could someone tell me what am I doing wrong..index/header/footer php would not come up

see the following links

index.php located under root
header.php located in root/inc/
footer.php located in root/inc

Kindest Regards

What are you using to edit the php text files with?


Your php include files look like you are pasting text into a prgram that is just displaying the code as text.

#39 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 09 December 2003 - 05:34 PM

I got the sucker to work, I reopened DW, create new php, copied and pasted the contents, saved them again, it worked this time....No other changes....it would appear to have to do with DW not recognizing these to be php files....

Thanks to all of you for helping....I now can move up to the same issue that Mutual Wisdom is discussing

How do I create two different columns, the left menu bar, and the content area using php? I grasped how to make the header, body, footer in the tutorial.


using DIV tags and CSS

Plz reply while the Iron is hot.........

Kindest Regards

#40 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 09 December 2003 - 06:13 PM

Great :dance:

you can also add
height="100%"
to the table to force the footer to the bottom of the screen for short pages.

As to the to column template
the link above to devshed does a very good job of showing how to make that type of template from a table



but for the same thing with just css
try
www.glish.com/css/
this can be adapted to php includes just as easy as the table method
but the css float command may not render properly in all browsers.

Edited by TCH-Don, 09 December 2003 - 06:23 PM.


#41 MutualWisdom

MutualWisdom

    New To The Neighborhood

  • Members
  • Pip
  • 12 posts

Posted 11 December 2003 - 01:10 PM

I made a post in a more relevant forum but still concerning the theme of this thread. This link will take you there.
divs and tables

Thanks for all the help so far! Thumbs Up

#42 MutualWisdom

MutualWisdom

    New To The Neighborhood

  • Members
  • Pip
  • 12 posts

Posted 19 December 2003 - 11:23 PM

My early experiments are going very well. Thank you all for helping me along!

With the use of php, as opposed to frames, will the entire page reload when clicking to another page in the site?

If a menu bar in a table stays the same, does it have to render again? I want only the content part of the table to look like it changes.

Thanks!
:)

#43 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 19 December 2003 - 11:48 PM

When all is said in done... it's just html.

If your html has frames, you get frames.

If it only has tables and divs, the page loads just like any html page with tables and divs.

It seems to me that elements from page to page that are exactly the same seem to load very quickly from the browser cache, and it often appears that the only thing changing is the content... but that's not exactly what's happening.

#44 Deverill

Deverill

    Immediate Family

  • Members
  • PipPipPipPip
  • 3,307 posts

Posted 20 December 2003 - 03:57 PM

Jack, great info here on PHP! Thumbs Up

One question I have is that I have a site with a couple-hundred pages that have page1.php, page2.php, page3.php and each of those have :
Include header
Include Content/page1.htm (or whatever it is)
Include footer

The problem is my 200 pages become 400 if I do it this way. The reason I did this was that I could go to Content/whatever.htm and change just the middle part without looking at the php include stuff.

My question that perhaps you or another could answer: Is there a way to have only one set of files without the messiness of php include statements in your content page? I was toying with an idea of a generic page that looks at how it's called and grabs the right "guts" and shoves that out as the page requested but I don't think I can make that work and it would probably be bad for the search engines.

Do you guys have any ideas how to clean up some of the fluff on my site?

Thanks!
"A winner is simply willing to do what a loser won't."

#45 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 30 December 2003 - 08:44 PM

After reading these great discussions, I have set out to overachieve again, plz advise if u see ways to follow recommended practices for efficient web site management.

First a site wide CSS style sheet:borrowing 3 column CSS style sheet at http://glish.com/css/7.asp and modifying the CSS code to make #rightcontent and #left content float at the bottom so as not be fixed. Saved all in a site wide style sheet detailed below.

Then the php files which will be called:
the header.php file header php This file references the following CSS :site banner, left content & right content
the footer.php file footer.php this file references the footer CSS

Then the actual index.php file which refences the centercontent CSS and has the includes to call up the header and the footer
index.php

The index.php code & CSS style sheet code are outlined below:

Have questions:
1. How do I modify the centercontent to line up with the left and right content?
2. How can the footer float so that it is positioned right at the bottom of the longest of the three colunms?
3. more questions later.....I promise

Thanks All, Dean

<?php
include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; 
?>
<link href="Assets/CSS/3col_leftNav.css" rel="stylesheet" type="text/css">
<div id="centercontent"> 
<?php echo "This is a test" ?>
      <p><img src="Assets/Images/traders.JPG" alt="" width="150" height="100"></p>
      <p>GHOST is about .............</p>
      <p>&nbsp;</p>
   <p>Main Body Goes Here........ what can GHOST do for U today </p>
</div>
</div>
<?php
include $_SERVER['DOCUMENT_ROOT']."/inc/footer.php"; 
?>


This is the code for the site wide CSS style sheet
/***********************************************/
/* 3col_leftNav.css                             */
/* Use with template 3col_leftNav.html          */
/***********************************************/
body {
	margin:5px 5px 0px;
	padding:0px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
  }
#leftcontent {
	position: absolute;
	left:10px;
	top:100px;
	width:120px;
	border:1px solid #000;
	background:#E5EAF1 /*#99ACC7*/;
	voice-family: "\"}\"";
  voice-family: inherit;
    /*	margin-left: 0px; 
   	 margin-right:121px; */
  padding-bottom:10px;
/*	<! height: 500px; !> */
  }

#centercontent {
	background:#FFFFFF;
	top:100px;
	margin-left: 130px;
	margin-right:160px;
	border:1px solid #000;
	voice-family: "\"}\"";
	voice-family: inherit;
	margin-left: 130px;
	margin-right:160px;
	float: none;
  }
html>body #centercontent {
   	 top:100px;
  margin-left: 130px;
   	 margin-right:160px;
  }

#rightcontent {
	position: absolute;
	right:10px;
	top:100px;
	width:150px;
	background:#FFFFFF;
	border:1px solid #000;
	/* height: 500px; */
	voice-family: "\"}\"";
	voice-family: inherit;
/*	margin-left: 150px;
	margin-right:0px; */
    padding-bottom:10px;
/*	left: 611px; */
/*	left: 462px; */
/*	left: 701px; */
  }
#banner {
	background:#fff;
	height:40px;
	border:1px solid #000;
	voice-family: "\"}\"";
	voice-family: inherit;
	height:39px;
  }
	html>body #banner {
  height:39px;
  }
	p,h1,pre {
  margin:0px 10px 10px 10px;
  }  
	h1 {
  font-size:14px;
  padding-top:10px;
  }  
	#banner h1 {
  font-size:14px;
  padding:10px 10px 0px 10px;
  margin:0px;
  }
	
	#rightcontent p {
  }
	#footer {
	height:20px;
	border:1px solid #000;
	height:20px;
	font-size: 9px;
	color: #CCCCCC;
	position: absolute;
	top: 850px;
	width: 100%;
	text-align: center;
	left: 10px;
  }
/***********************************************/
/* Layout Divs                                 */
/***********************************************/

#masthead{
	padding: 10px 0px 0px 0px;
	border-bottom: 1px solid #cccccc;
	width: 100%;
}

#navBar{
	float: left;
	width: 20%;
	margin: 0px;
	padding: 0px;
	background-color: #eeeeee;
	border-right: 1px solid #cccccc;
	border-bottom: 1px solid #cccccc;
}

#headlines{
  float:right;
	width: 20%;
	border-left: 1px solid #cccccc;
	border-bottom: 1px solid #cccccc;
	padding-right: 10px;
}

#content{
	float: left;
  width: 55%;
}

/***********************************************/
/* Components                                  */
/***********************************************/

#siteName{
	margin: 0;
	padding: 0 0 0 10px;
}
/************* #globalNav styles **************/

#globalNav{
	padding: 0px 0px 5px 0px;
	border-bottom: 1px solid #CCC;
	color: #cccccc;
	font-size: 100%;
}

#globalNav img{
 display: block;
}

#globalNav a {
	font-size: 90%;
	padding: 0 4px 0 0;
}
/*************** #pageName styles **************/

#pageName{
	margin: 0px;
	padding: 0px 0px 0px 10px;
}

/************* #breadCrumb styles *************/

#breadCrumb{
	font-size: 80%;
	padding: 2px 0px 0 10px;
}

/************** .feature styles ***************/

.feature{
	padding: 0px 0px 10px 10px;
	font-size: 80%;
}

.feature h3{
	padding: 30px 0px 5px 0px;
	text-align: center;
}

.feature img{
	float: left;
	padding: 10px 10px 0px 0px;
}

/************** .story styles *****************/

.story{
	clear: both;
	padding: 10px 0px 0px 10px;
	font-size: 80%;
}

.story p{
	padding: 0px 0px 10px 0px;
}


/************* #siteInfo styles ***************/

#siteInfo{
	clear: both;
	border: 1px solid #cccccc;
	font-size: 100%;
	color: #cccccc;
	padding: 5px 10px 0px 10px;
}

#siteInfo img{
	padding: 4px 4px 4px 10px;
	vertical-align: middle;
}


/************* #search styles ***************/

#search{
	padding: 5px 0px 5px 10px;
	border-bottom: 1px solid #cccccc;
	font-size: 90%;
}

#search form{
 margin: 0px;
 padding: 0px;
}

#search label{
	display: block;
	margin: 0px;
	padding: 0px;
}
/*********** #navBar link styles ***********/

#navBar ul a:link, #navBar ul a:visited {display: block;}
#navBar ul {list-style: none; margin: 0; padding: 0;}

/* hack to fix IE/Win's broken rendering of block-level anchors in lists */
#navBar li {border-bottom: 1px solid #EEE;}

/* fix for browsers that don't need the hack */
html>body #navBar li {border-bottom: none;}


/*********** #sectionLinks styles ***********/

#sectionLinks{
	position: relative;
	margin: 0px;
	padding: 0px;
	border-bottom: 1px solid #cccccc;
	font-size: 90%;
}

#sectionLinks h3{
	padding: 10px 0px 2px 10px;
}

#sectionLinks a {
	display: block;
	border-top: 1px solid #cccccc;
	padding: 2px 0px 2px 10px;
}

#sectionLinks a:hover{
	background-color: #dddddd;
}


/*********** .relatedLinks styles ***********/

.relatedLinks{
	position: relative;
	margin: 0px;
	padding: 0px 0px 10px 10px;
	font-size: 90%;
}

.relatedLinks h3{
	padding: 10px 0px 2px 0px;
}

.relatedLinks a:link,
.relatedLinks a:visited {
	display: block; 
}

/************** #advert styles **************/

#advert{
	padding: 30px 0px 10px;
}

#advert img{
	display: block;
}


/************** #headlines styles **************/

#headlines{
	margin: 0px;
	padding: 10px 0px 20px 10px;
	font-size: 80%;
}

#headlines p{
	padding: 5px 0px 5px 0px;
}


#46 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 06 January 2004 - 04:08 PM

Hi folks....is the post too long, wordy? Plz sound off, silence is the cruelest...

Thanks, Dean

#47 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 07 January 2004 - 07:35 AM

Have questions:
1. How do I modify the centercontent to line up with the left and right content?
2. How can the footer float so that it is positioned right at the bottom of the longest of the three colunms?
3. more questions later.....I promise


These are CSS questions that you are posting in a thread on using php to make headers and footers on your page... a rudimentary templating system.

The templating system written in php (which you appear to be using correctly) is just outputting html. So the php has zip to do with positioning.

If you already know this, my apologies. But it would be best to repost this in a new thread in a category where CSS is discussed.

I think that's why you didn't get any attention.

#48 deanavail

deanavail

    Family Friend

  • Members
  • PipPip
  • 94 posts

Posted 07 January 2004 - 11:32 AM

I am greatful for a reply...........Dean

#49 MitchO

MitchO

    New To The Neighborhood

  • Members
  • Pip
  • 9 posts

Posted 08 January 2004 - 01:56 PM

Hiya folks. I've been anxiously waiting to use this php tutorial since the thread started, and i finally have had a free minute to start working on it. The good news is, i seem to be getting the hang of it and i've got it working.

The bad news is, i have a full index.html file out there, and now that i have an index.php file, i'm concerned about the default, and the people who may have linked the front page with "/index.html" in the url.

Is there a way i can have them both there, named index with different extensions? My testing indicates that the html one is coming up as the default. What i'd like to do is make the php one the default, and put a redirect and a request to update your link in the html one. Is that possible?

For the record (and the curious), the site is LennonOkun.com and the "future" default site is index.php.

#50 surefire

surefire

    Immediate Family

  • Members
  • PipPipPipPip
  • 1,008 posts

Posted 08 January 2004 - 04:05 PM

Just do a 301 redirect

in .htaccess

301 redirect /index.html http://www.[youractualsite].com/index.php

#51 MitchO

MitchO

    New To The Neighborhood

  • Members
  • Pip
  • 9 posts

Posted 09 January 2004 - 10:57 AM

EDIT: I didn't fully understand the above post, but i did find the redirect option in CPanel and evidently i can redirect from index.html to index.php and rename index.html so it isn't a choice for future defaulting. Yay CPanel and TCH!~ Rock Sign

#52 SlitheryImp

SlitheryImp

    Family Friend

  • Members
  • PipPip
  • 26 posts

Posted 29 February 2004 - 02:58 PM

Thankyou very much for that tutorial! No more "Frontpage shared borders" :lol:

I think I'm going to have to learn some more of this php stuff :)

#53 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 29 February 2004 - 03:24 PM

PHP, by default, will only execute PHP code if the file ends in .php.
It simplifies things for the server if it only needs to monitor one specific file extension.

If you login to your cPanel > Site Managment,
you will see an option for Apache Handlers.
On that page, add .html files to the PHP-executable list:

in the window for Extensions: type
.htm .html

and in the Handler: window type
application/x-httpd-php

When you are done, you should see

User Defined Handlers
.htm .html application/x-httpd-php

System Defined Handlers
.cgi .pl cgi-script
.shtml server-parsed


With this information,
the server should be able to execute your HTM and HTML files as PHP.
And search engines will not have a problem with missing pages.

hope this helps

Edited by TCH-Don, 29 February 2004 - 03:26 PM.


#54 SlitheryImp

SlitheryImp

    Family Friend

  • Members
  • PipPip
  • 26 posts

Posted 01 March 2004 - 09:59 AM

Is that also possible with .shtm or .shtml pages?

I would like to use the random html generator, but I can't get it to work with .php files, or am I doing something wrong?

#55 TCH-Don

TCH-Don

    Immediate Family

  • Members
  • PipPipPipPip
  • 11,642 posts

Posted 01 March 2004 - 11:09 AM

User Defined Handlers
.htm .html application/x-httpd-php
.shtm .shtml application/x-httpd-php
System Defined Handlers
.cgi .pl cgi-script
.shtml


just added
.shtm .shtml
and tried it on my 404.shtml
to add a copyright

<P ALIGN="center">
copyright&copy;<?php echo date("Y") ?>
</P>

and it works fine,
thanks for the idea Thumbs Up

#56 D.Slatk

D.Slatk

    Family Friend

  • Members
  • PipPip
  • 80 posts

Posted 07 March 2005 - 11:09 PM

I just want to add one thing to the layout part, I don't think he mentioned it but this is an option. It lets you change the titles set for the pages very easily. For example lets say you have this on your fruits and vegetables page of a healthy eating site:

<?php $pageTitle = 'Healthy Eating: Fruits and Vegetables'; include (file.inc); ?>
Content
<?php include (footer.inc); ?>

And in the header.inc you will then have this code:

<html><head><title><?php echo $pageTitle; ?></title</head><body
<table...> etc

This make it so you can change the title of the page on your web site. In this case, your title would come out as the variable you defined in the first block of code I showed you. You can change it for each page and so then each page will come out differently. :eek:

One more thing (again, I don't know if this has been mentioned, heh). Use single quotes if all you have are text and characters that you're going to use. That way the server processes it just a little little little bit faster. If you use double quotes, the server will have to parse it while checking for variables and the like. For example:

<?php

$singleQuotes = 'testing the single quotes';
echo '$singleQuotes and does it work?<br />';
echo "$singleQuotes and does it work?<br />";
echo 'Another way of ' . $singleQuotes . '<br /><br />';

$singleQuotes2 = "$singleQuotes with storing it in a variable";
echo $singleQuotes2;

?>

You would get:

$singleQuotes and does it work?
testing the single quotes and does it work?
another way of testing the single quotes

testing the single quotes with storing it in a variable


Tell me if that those made any sense at all :)

#57 carbonize

carbonize

    Immediate Family

  • Members
  • PipPipPipPip
  • 828 posts

Posted 03 April 2005 - 11:50 PM

In contrast, JavaScript is a client side code.† Your visitor has to have Javascript turned on and installed in order for all the neat javascript to work on your website

<{POST_SNAPBACK}>

Small point but Javascript can also be serverside or am I imagining things again :-/ also you don't install javascript.

In regards to how this forum deals with it's header and footer they are actually stored in MySQL and either loaded into a buffer or an array when called. Can't remember which.

Edited by carbonize, 03 April 2005 - 11:52 PM.

Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

#58 TCH-Dick

TCH-Dick

    General Manager

  • Admins
  • PipPipPipPip
  • 5,786 posts

Posted 04 April 2005 - 12:59 AM

I had to read this whole thread again to see what you were talking about. :cool2:

Small point but Javascript can also be serverside or am I imagining things again :-/ also you don't install javascript.

Yes JavaScript can be serverside, but I believe the server has to be running the JavaScript runtime engine. Which I think is not supported here.

In regards to how this forum deals with it's header and footer they are actually stored in MySQL and either loaded into a buffer or an array when called. Can't remember which.

It is stored in MySQL but you can also have it create a cache of php files, if I remember correctly. This particular thread though refers to IPB 1.2, which was the version in use here when this thread was created. IPB 1.2 is also what is included with cPanel and used by alot of users here.

Dick DeVance
General Manager
TotalChoice Hosting, Inc
dick@totalchoicehosting.com


Posted Image


#59 carbonize

carbonize

    Immediate Family

  • Members
  • PipPipPipPip
  • 828 posts

Posted 04 April 2005 - 01:16 AM

In regards to how this forum deals with it's header and footer they are actually stored in MySQL and either loaded into a buffer or an array when called. Can't remember which.

It is stored in MySQL but you can also have it create a cache of php files, if I remember correctly. This particular thread though refers to IPB 1.2, which was the version in use here when this thread was created. IPB 1.2 is also what is included with cPanel and used by alot of users here.

<{POST_SNAPBACK}>

Wow another good example of why hosts should advise clients not to install scripts supplied by cPanel. I mean the last free version of IPB was 1.3.1 and here is cpanel offering 1.2. I think cPanel probably has a lot to answer for when it comes to the number of sites that get defaced due to running old scripts.
Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

#60 TCH-Bruce

TCH-Bruce

    Volunteer Moderator

  • Members
  • PipPipPipPip
  • 19,960 posts

Posted 04 April 2005 - 08:00 AM

Wow another good example of why hosts should advise clients not to install scripts supplied by cPanel. I mean the last free version of IPB was 1.3.1 and here is cpanel offering 1.2. I think cPanel probably has a lot to answer for when it comes to the number of sites that get defaced due to running old scripts.

<{POST_SNAPBACK}>

I'm not sticking up for cpanel but I am sure they are only allowed to use what ever the vendor allows them to license.

Since IPB is no longer free, maybe IPB won't allow cpanel to offer 1.3.1 final with their distribution.

That said, it is the user's responsibility to be sure scripts are maintained and all security patches applied.

Bruce Richards
Forum Moderator
TotalChoice Hosting, Inc.
Webhosting by Total Choice Web Hosting - General Support Forum

I am a Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.


#61 carbonize

carbonize

    Immediate Family

  • Members
  • PipPipPipPip
  • 828 posts

Posted 04 April 2005 - 09:00 AM

yes but as some posts in here have indicated people assume that the version offered by cPanel is the latest version.
Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

#62 TCH-Bruce

TCH-Bruce

    Volunteer Moderator

  • Members
  • PipPipPipPip
  • 19,960 posts

Posted 04 April 2005 - 09:20 AM

Can't argue with that, but we all know what "assume" means. :cool2:

Bruce Richards
Forum Moderator
TotalChoice Hosting, Inc.
Webhosting by Total Choice Web Hosting - General Support Forum

I am a Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.


#63 thedesignstudent

thedesignstudent

    Family Friend

  • Members
  • PipPip
  • 31 posts

Posted 11 February 2008 - 06:54 AM

Hi, Iím Dave. designyourowndenim.thedesignstudent.com
The site is my example thatís up and running.


I need php. My site is 50+ pages. I want to change the light pink and and light blue menus on either side of the center frame into mouse-over movies/animations in flash. I made my first flash button and Iím ready to go.

With html Iíd need to update all 50 pages manually, but Iíd like to go the php route, alter 2 files and have all 50 and growing pages update by themselves.


I also noticed I forgot to add the shopping category skirts, and maybe Iíd like to have a logo created in 6 months or add a new product and update on the entire site.

I created one of the mouse-over buttons in Flash and Illustrator (gif), but Iíve been hesitant in doing it all manually. Sure it was great in the beginning when I thought I had the template I wanted to use, but needs have changed and fast, as they do every day.


So are you saying that for me changing 2 pages would still be possible with php? Any other tutorials that would help me on the way towards asking better questions and whatís the best program to use for creating php pages?

I use front page, and it alters the php code/tags (<) placed into the html editor into tags &lt; etc.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users