- Working with PHP
PHP is a powerfull tool that lets you create dynamic web pages.
PHP-enabled web pages are treated just like regular HTML pages and you can create and edit them the same way you normally create regular HTML pages.
We have the latest PHP version installed on all of our web servers and is available to all of our customers at no additional charge.
We are using the CGI version of PHP so you must make all you php files executable and have the path to the php binary at the top of your page.
(the code needs to be on the top of every page that uses php)
Creating a simple php webpage
1) Copy this php code below (do not include the "---") to text file and name it "test.php" on your computer. You MUST use a text editor. Do not use programs such as Frontpage, Dreamweaver, Wordpad, or any other editing tools. To be on the safe side, we recommend you use NOTEPAD which is available in all versions of Windows.
2) Now, upload this file (test.php) in "ascii" mode to your "www" directory.
3) Change the permission of the "test.php" file to "755".
4) That's it! Now, call up this page through your domain name (http://www.yourdomain.com/test.php).
NOTE: If you are getting a 500 Internal Server Error, 99% of the time you must have done something wrong with the precedures above, or used something else than a plain text editor like Notepad.
- Working with Server Side Include (SSI)
Server Side Include (SSI) commands are executed by the server as it parses your HTML file.
Server side includes can be used to include the value of various server environment variables within your HTML such as the local date and time.
All SemoTech Web servers are already SSI enabled, all you need to do is call your webpage using .shtml extension instead of the usual .html.
To get a better understanding, look at the table below. You can use SSI commands to display what the time and date is when anyone access your website or record the IP address.
Comment Tag as HTML:
Today's date and time is <!--#echo var="DATE_LOCAL" -->
Today's date and time is Tuesday, 19-Jun-2001 03:29:15 EDT
Comment Tag as HTML:
Your IP number is <!--#echo var="REMOTE_ADDR" -->
Your IP number is 18.104.22.168
Remember, HTML files containing SSI must be named with an .shtml extension. SSI commands are easy to add to your HTML, but you must follow the syntax exactly:
Adding SSI to your website
1) Simply open any of your existing html page
2) Add the SSI command (i.e. <!--#echo var="DATE_LOCAL" -->) to between the <body> </body> tags in your HTML.
3) Save that file as filename.shtml (i.e., if your webpage was "about.html", save it as "about.shtml")
4) Upload the file to the server and call your that page on your browser (http://www.yourdomain.com/filename.shtml). That's it! If you did everything right, you will see the time and date on your webpage.
- Working with Common Gateway Interface (CGI)
CGI stands for "Common Gateway Interface". It is a server-side communication standard supported by all web servers for accessing external programs. Examples of CGI programs are gateways to databases and scripts that process and return HTML commands to the server. Since HTML allows only one-way communication from the server, which is read by the web browser or client, CGI permits communication and interaction from the client to the server for two-way, dynamic web pages.
CGI is processed by the Pearl language interpreter and therefore all CGI script files, used in an account hosted by SemoTech, must begin with the following line:
(this code needs to be the very first & at the top of every CGI script page)
Creating a simple email form using CGI:
Email forms are used to gather information from a visitor to your website and return that information only to you (or a designated email address). More complex scripts caller "Referrers" can be used to send invitations to your website to 3-rd party email addresses thus advertising your site.
To create a simple email form you have 2 choices:
1) Use the system provided FormMail script.
2) Use your own script by placing it in the cgi-bin folder on your account and setting the appropriate 755 permissions on it using your FTP client or publishing software.
Choice 1: FormMail is a simple to use, generic HTML form processor which emails the results of any form to a pre-specified recipient. Unlike other form scripts, FormMail poses no security risk for the server, and can be used for almost any kind of feedback form required - orders, enquiries, statistic gathering etc. Basically any kind of "inbound" only form.
To use the SemoTech provided FormMail script you'll need to properly call it with the following syntax in your form code:
<form action= "/cgi-sys/FormMail.cgi" method=POST>
<input type="hidden" name="recipient" value="firstname.lastname@example.org">
<input type="hidden" name="subject" value="Feedback from web site">
<input type="hidden" name="redirect" value="http://www.yourdomain.com/thankyou.htm">
For additional information on the provided FormMail script and syntax of the fields, see this link:
Choice 2: Create, or download and modify, your own CGI script and place it in the cgi-bin folder in your SemoTech account. Remember to set the access permissions to 755.
Proceed to call it in your form HTML using the following syntax:
<form action="/cgi-bin/your_script_name" method=POST>
Depending on the script you use or create you will have to stick to your script requirements for syntax of the field names to ensure the proper information is returned.
Since using a custom script gives you virtually limitless functionality, you must be very careful in its use due to security vulnerabilities, exploits and the ban on SPAM. Creating or using CGI scripts that send out mass emails or target individual emails with unsolicited messages can result in lawsuits being filed against you. Exercise caution, inquire with SemoTech whenever you are in doubt and use your head.
For thousands of examples of CGI scripts take a look here: