I Teach PHP.com

Apache Apache1.3 to 2.0
Configuration Basics
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
SSH Clients
Virtual Hosting
links
syllabus
apache-refcard-letter

Bash Bash Shell Tips And Tricks
bash

CSS CSS2 Reference
links
syllabus

DHTML syllabus

HTML Basic HTML Tags
Creating Images
links
syllabus

Linux Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
Linux Basics
SSH Clients
links
mailme

Linux Clusters Cluster Books
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
SSH Clients
syllabus

Linux Security Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
PHP Security
SSH Clients
Security QuickRef
UnixSecurity2.0
syllabus

Linux SysAdmin Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
PHP Security
SSH Clients
Security QuickRef
UnixSecurity2.0
syllabus
show book

Linux for Business Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
syllabus
show book

PHP 4 page DB system
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
Linux Basics
PHP Security
Password Protect
Perl CGI Problems
Perl vs. PHP
Yahoo Stocks
links
syllabus

PHP for Flash 1-Flash Intro
2-Flash-PHP Form
Flash-PHP FAQ
Linux Basics
SSH Clients
syllabus

Perl Perl CGI Problems
SSH Clients
syllabus

TCP-IP Subnetting Tutorial
links

WML Yahoo Stocks
links
syllabus

cgi-bin

E-MAIL
Untitled Document

Perl vs. PHP

Perl is a widely-used programming language used to process CGI (Common Gateway Interface) information.  Unfortunately, it is challenging to write and debug.  Let's begin with an HTML form to collect a visitor's first name and last name (we'll call it form.html):

   <html>
   <body>
   <form action="cgi-bin/name.cgi" method="post">
     What is your first name?<INPUT type=text name=first><BR>
     What is your last name?<INPUT type=text name=last><BR>
     <INPUT type=submit>
   </form>
   </body>
   </html>

Here is an example of a Perl script (we'll call it name.cgi). It should be noted that this script will have to be placed in a special directory (often called cgi-bin) which the web server knows about and is configured to allow program execution. The permissions of the script must be set to allow execution as well. Getting this all working can be complicated.

   #!/usr/bin/perl -Tw
   
   # askname.cgi from PROFESSIONAL APACHE

   use CGI;
   use strict;
   my $cgi=new CGI;
   print $cgi->header();
   print $cgi->start_html("CGI Demo");
   print "Hello, ",$cgi->param("first")," ",$cgi->param("last");
   print $cgi->end_html();

If we modify the action parameter in the <FORM> tag to point to a PHP script:

   <HTML>
   <BODY>
   <FORM action="name.php" method=post>
     What is your first name?<INPUT type=text name=first><BR>
     What is your last name?<INPUT type=text name=last><BR>
     <INPUT type=submit>
   </FORM>
   </BODY>
   </HTML>

Here is an HTML page which includes PHP code (which we can call name.php), we can perform the same task as the Perl script in a much simpler and shorter set of code:

   <HTML>
   <BODY>
   <?php
     extract($_POST);
     print "Hello, $first $last";
   ?>
   </BODY>
   </HTML>

The actual PHP code is quite simple, we are simply printing the contents of the two variables which have been passed from the form.  The rest is HTML.


This site contains files and links to support the free courses taught by James D. Keeline at the New Media Center / North City Center through the San Diego Community College District's Centers For Education and Technology.   A list of courses available at the center may be consulted.

The site will be updated throughout the semester both with new content and as a way to try out technologies used in several of the classes. This file modified 14-Jan-2007.