URL: http://www.stkate.edu<?php print $PHP_SELF?><br /><?php $last_revised = date("F d, Y", getlastmod());print "Last revised: $last_revised<br />"; ?></body></html>
Step 5: Save this file as footer.php and FTP it to paradox.stkate.edu.
This is the end of the XHTML we started in header.php. Again, this file will never beused alone. It will always be used in conjunction with at least one other file. There arealso two other bits of PHP code in the file. First of all, we have the environment variable$PHP_SELF. An environment variable is a variable that you don’t specify yourself. Itcomes automatically with the server running PHP. There are a bunch of them, but for our purposes we will just deal with this one. $PHP_SELF is a variable that holds the value of the name of the file itself. So, by printing it out in this way, we can print out the actualURL of the file dynamically. This means, if all goes as planned, we shouldn’t have tokeep manually writing out the file name on this line. PHP will do it for us every time weuse footer.php. Slick, heh?Secondly, the footer.php file contains some “last revised” information which lets thereader know when was the last time this page was updated. Again, why should we haveto manually type this information in when the server will do it for us? So, first of all wecreate a variable named $last_revised. And we assign that variable the value of
date("Fd, Y", getlastmod()).
I know what you are thinking: huh? What this is is thedate() function of PHP. PHP comes with a whole bunch of built in functions that extendthe power of the programming language. In this case, this function let’s us work withdates. Specifically, it prints out the date in “F, d, Y” format. In the date() function, the“F” stands for the month, the “d” stands for the day, and the “Y” stands for the year.Check outhttp://us2.php.net/manual/en/function.date.phpfor more date codes that youcan try. We also specify another function inside the date function: getlasmod(); thisfunction obviously gets the last modified date from the server for the file it is used on.Used with the date function and our fancy coding we print it out for the user to see. Atleast that is the goal. Let’s move on.So, we’ve got the header and footer for our site. Now all we need is a file to attach these puppies to. So, let’s create a file, but this won’t be any ordinary file. It will be one onwhich the user can finally interact with our site. It will be a mail form!
Step 6: Open Notepad (or Simpletext) and create a New document. Type inthe following code:
<?php$title = “Mail form”;include(“header.php”);?><p>Thanks for taking the time to let me know what you think of myhumble site. Please use the form below to submit your comments tome:</p>
Leave a Comment