Jim,
I just figured out how to use PHP to reduce a template to a number of references to PHP files. It’s OK but I’d rather do it a different way. Isn’t there a way to have a template on the screen and when a link is clicked, the page doesn’t reload, rather the area of text the viewer wants to read changes to the information the viewer chose (by having clicked the corresponding link). This way the template loads only the initial time and the template contains a bunch of references to a bunch of files of text, one of which the computers would fetch when a link is clicked. That would be very efficient.
For example on my site, the text is found in the middle column for each different page of the site. If one of the links in the right or left column is clicked, instead of reloading the template with the chosen information text (aka "going to that page"), why not leave the template there, don’t reload the template, and when the viewer clicks a link, load the text the viewer wants to read into the center column. What language would I use to accompolish this and what would be the enabling function(s) of that language that would accompolish this?
Thanks,
Roger

Hi Roger,
That would not be search engine friendly – You’re talking about the page staying the same, but the text changing right?
PHP is the most widely supported language and is what you should use. Play with it for a while – or – I can give you a basic site layout, code and all, so that you can try it on your site if you’re interested.
Also – if you have pages that are well linked to and have good Google PR, then you don’t need to change the filename, we can tell your system to execute your existing code as PHP – it’s a Big mistake many website owners make that will cost you in the long run.
You could play with frames and it’s not something I have done much with, but again, I don’t think this is the way to go. The best way would be PHP with includes.
Best regards,
Jim.
I don’t think I’m well linked and my site is not ranked by Google so should I still work to keep my file names _ _.html.
Another two reasons not to use a true template is loss of space to advertise, or a lot of work to get the adds to change when a different link is clicked. The other is that it’s not worth the trouble becuase my template is only 12kb.
I read about ajax programming to create true templates and it’s too much for me.
webreference.com/programming/javascript/jf/column12/index.html
What about that executing .html code as PHP code? Is it true that once you add a little PHP to HTML the code will work fine when executed as PHP? Don’t you have to have 100% PHP code to execute as PHP code?
Thanks,
Roger
If the pages are not well linked, then you can use other page names if you choose, but, yes, you can run the html as php.
The php does not have to be all php, and in most cases, they are not.
Here are the contents of a index.php page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PHP Information</title>
</head>
<body>
<p>Hello, your computer is using IP Address
<?php
// prints out the IP Address
echo $REMOTE_ADDR;
?>
and today is
<?php
// prints something like: Mon, 21 Aug 2007 4:12:46 UTC
echo date(DATE_RFC822);
?>
</p>
</body>
</html>
The index.php page is just like any html page, except that it has php code in it. The <? and ?> mark the start and end of the php code. The // is simply a comment and will not show on the screen, it is just for you (the coder).
If you cut and paste that text into a file, say ipinfo.php, and place it on the main directory of your website, you can then call it using yoursite.com/ipinfo.php and it will display the IP address of any visitor that views this page.
Now, let
JIm,
Thanks for all the info!
When you say to add to my HTAccess file "AddType application/x-httpd-php .html" , is that a space between php and .html? And can I put that in now even though I havn’t written any PHP code into my site and the site will still work right?
Thanks,
Roger
Now, let’s look at using php for include files with your template or webpage.
Copy the contents of between the —– lines below and paste it into a file called main1.php
————————-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome</title>
</head>
<body>
<p>Welcome to my site! Use the links below to navigate my site!</p>
<?php include("menu1.php"); ?>
<p>Thanks for visiting!</p>
</body>
</html>
————————-
Now, copy the contents between the dashes below and paste them into another file called menu1.php.
————————-
<a href="example.com/index.php">Home</a> –
<a href="example.com/about.php">About Us</a> –
<a href="example.com/links.php">Links</a> –
<a href="example.com/contact.php">Contact Us</a> <br />
————————-
You should now have two files in the main directory of your website called main1.php and menu1.php. When you type in your website address example.com/main1.php you should see a full page.
Look at the source (view source under the browser tab) and you’ll also notice that there is no php code, it’s all html!
This is the way all the big sites operate and in fact, they have to, or they would never be able to manage their sites.
Regards,
Jim.
Jim,
You write, "The index.php page is just like any html page, except that it has php code in it." If I write a site using PHP, and I wanted the date on every page, wouldn’t I use the PHP code for the date on every page? What about when I convert my left and write columns of my template to PHP and the include function (so I can change the colums with ione edite and all the pages will change), wouldn’t I have to have that PHP code on every page, if not what would I put inplace of the code I have now for the two colums on the non index pages?
Thanks,
Roger
Roger,
You would have to edit every page and take out the content on the right and left columns, replace that content with the includes, and paste the removed content into the include files. I know, that’s seems like a lot of work, but once it’s done, then you only have to modify the include file rather than every page.
As for the date, you would visit every page and remove put an include where you would like the date, then the date would appear on each page. Now, you can just add the date code to each page and not make an include with the date code, but if you ever wanted to remove or modify the date, then you would have to again, visit every page.
Regards,
Jim.
Jim,
I thought that’s what I would have to do (the last time I would have to make the same change to every page)
I think you meant a .php page is like any other page except it has PHP code in it. I lost track by the "index" of "index.php". It’s ironic but the more I write, the less I understand what people are saying.
When you say to add to my HTAccess file "AddType application/x-httpd-php .html" , is that a space between php and .html? And can I put that in now even though I havn’t written any PHP code into my site and the site will still work right?
Thanks Jim,
Roger
Hi Roger,
Yes, php is like any other page except it has php in it – yes.
The index.php page is the common name for the main page of a website in php. In asp, it would be default.asp, etc. Each language has a set of pages it checks when someone visits the website without using a page. For example, if I type type websecurity.mobi in the browser, my server will first check my files to see if there is a index.php file and if so, it executes the content and displays it on the screen. I can tell it to also check for another file if the index file does not exist, etc.
Yes and Yes – Yes, that is a space and yes, you can enter that line right now and everything will run fine, then, as you add php code, it will run automagically!
Regards,
Jim.
Jim,
Thanks for clarifying that.
Roger
Jim,
Recently a Bluehost automated program of some sort changed the code in my HTAccess file for what to do during an error to
ErrorDocument 400 /index.php?error=400
ErrorDocument 404 /index.php?error=404
#ErrorDocument 500
ErrorDocument 503 /index.php?error=503 .
I don’t know what it was beforehand, but here’s the code for the errors
<?php get_header(); ?>
<div id="content">
<div id="colmid">
<div id="colleft">
<div id="col1wrap">
<div id="col1">
<?php
if(!isset($_REQUEST['error']) && ($_REQUEST['error'] == 400 || $_REQUEST['error'] == 503))
echo "<h2>Bad Request/Server Error <small>(400/503 Error)</small></h2><p>There was a technical error. Please try again.</p>";
else
echo "<h2>No Such Page <small>(404 Error)</small></h2><p>There’s no such webpage.<br />If you typed the address, please check your spelling and placement of symbols, otherwise the information was moved to other pages.<br /><br />Please try searching for it again.</p>";
include (TEMPLATEPATH . ‘/searchform.php’);
?>
<br /><br />
</div>
</div>
</div>
</div>
</div>
I think the change was made to compensate for not having up to date code for compiling PHP in HTML.
Bluhost has a procedure you enter from their control panel for making PHP work inside HTML. The code in the HTAccess file for making PHP work inside HTML use to be
AddType application/x-httpd-php .html .php .htm
AddHandler application/x-httpd-php .html .php .htm
now the new updated way is
# Use PHP5CGI as default
AddHandler application/x-httpd-php5 .html .php .htm
My HtAccess file is up to date with this code now. (The requirment of having this code right and not having it right completely crashed my site.)
What should these error codes
ErrorDocument 400 /index.php?error=400
ErrorDocument 404 /index.php?error=404
#ErrorDocument 500
ErrorDocument 503 /index.php?error=503
be changed to
Thanks Jim,
Roger
Rather than telling the system to fetch a certain page for a certain error code, the code you have sends all errors (400,404,500, 503) to index.php. Index.php then checks for these errors and if found, then send the appropriate message.
If your webhost put that into your htaccess, then there must have been a reason and they should have given you detailed instructions – What that should be changed to I am not sure as I’m not sure what there intention was, but, here is some great information on setting up error pages for WordPress:
ht tp: //codex.wordpress.org/Creating_an_Error_404_Page>
Hope that helps!
Best regards,
Jim.