We are proud to offer Offer Full Service Networking support and managed services for your growing business.

Chapter One - General Account Information
Chapter Two - Control Panel
Chapter Three - FTP Instructions
Chapter Four - Telnet Instructions
Chapter Five - POP3 Email Settings
Chapter Six - Mail Manager & Smart Lists
Chapter Seven - Microsoft FrontPage
Chapter Eight - Anonymous FTP
Chapter Nine - Site Statistics
Chapter Ten - Password Protect Dirs

Chapter Eleven - CGI-Bin, Formmail
Chapter Twelve - Secure Socket Layer (SSL)
Chapter Thirteen - Changing Passwords
Chapter Fourteen - PGP & PGP Mail
Chapter Fifteen - Redirect URL
Chapter Sixteen - MySQL
Chapter Seventeen - Troubleshooting Faqs
Chapter Eighteen - PHP/SSI
Chapter Nineteen - Real Audio/Real Video
Chapter Twenty - Policy & Disclaimer

CHAPTER EIGHTEEN - PHP/SSI


PHP

What is PHP?

PHP is a server-side HTML embedded scripting language that was developed in C and is designed especially for working with relational database systems.

How do I set up a PHP Program?

A PHP program is embedded directly in the HTML document. It must have a .phtml extension in order for the server to look for PHP code in the document. Here is how you embed the PHP:

<?
insert PHP code here
?>

How do I work with a MySQL database using PHP?

1.To merely display the information in your database without the use of a form to call a php script you simply create your HTML document as you would any other web page but instead of the extension of .htm or .html you need to name the file with the extension .phtml. Then within the document itself the section that you'd like to be the PHP code, you begin it with <? and end it with ?>. For instance:

<P>These are the products I sell:</P>

<TABLE BORDER="1">

<?
mysql_connect(localhost, username, password);
$result = mysql(mydatabase, "select * from products");
$num = mysql_numrows($result);
$i = 0;

while($i < $num) {
echo "<TR>n";
echo "<TD>n";
echo mysql_result($result,$i,"prodid");
echo "</TD>n<TD>";
echo mysql_result($result,$i,"name");
echo "</TD>n<TD>";
echo mysql_result($result,$i,"price");
echo "</TD>n";
echo "</TR>n";
$i++;}
?>
</TABLE>

Thus having the loop in the php program create a table with the products listed. NOTE your username and password for the database are not written in the file when it's displayed on the Internet so users viewing the source of your webpage will not see your password.

2.When using a CGI script to pull information from a form which has been submitted by a browser you must have the first line of the script have this command on it (Much like perl scripts):

#!/usr/local/bin/php

For detailed information regarding PHP, you can go to their online manual:

http://www.php.net/manual



SSI

The simplest example of server-parsed HTML is to have a file "foo.shtml" containing this text:

Line one
<!--#exec cgi="mycgi.cgi" --><P>
Line three

And then have a file "mycgi.cgi" that contains, on Unix:

#!/usr/bin/perl

print "Content-type: text/htmlnn";
print "Line Two";


And when you access "foo.shtml", it will output:

Line one
Line two
Line three


If your include directive is <!--#exec cgi="..." -->, then the cgi program you run must output a standard CGI header (Content-type: text/html)


Any file named foo.shtml will be parsed automatically by Apache on our servers.
Do not put any spaces before the '#' character in your include directives; if you have "<!-- #exec" instead of "<!--#exec", the line will be ignored.

Server-side includes in "custom trailers" will not work, since custom trailers are appended to the output of your web pages after all other processing has been done on them. Any server-side includes that you put into your custom trailers will be sent directly to the browser without being parsed.

More Help for using SSI can be found at:
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html
http//bignosebird.com/ssi.shtml
http//getscript.com/ssi.shtml
http//carleton.ca/~dmcfet/html/ssi2.html
http/sonic.net/~nbs/unix/www/ssi/
http//useforesite.com/tut_ssi.shtml



Back to the top



Back to the top