![]() |
Displaying the Current Date![]() ![]() ![]() ![]() ![]()
First, a typical CGI date.cgi which displays the local date and time, does two things: * Calculates the current time * Displays the time The most challenging part of the program will be to figure out how to calculate the time, so we'll begin there. In Perl, calculating the date and time is easy.. Shown below is the Perl code for printing the clate. ($sec, $min, $h, $day, $mon, $y, $week, $dayofyear, $isDST) =localtime(time()) $mon ++; print "$day/$mon/$y and time is > $h $min $sec"), The localtime() function converts the value returned by the system's time function into familiar time components such as day, month, year, and so of Now that you know how to calculate and print the current local time, you want to incorporate this into a CGI program. Instead of printing the date to the screen you want to print it to the Web browser. #print CGI headerprint "Content-Type:text/html\n\n; ($sec,$min,$h,$day,$mon,$week,$dayofyear,$isDST)=localtime(time()); $mon++; #now print the date and time print"<html><head>\n"; print"<title>Current Date and Time</title>\n; print"<head><body>\n"; print"<h1>The date is now</h1>\n"; print"<p>Date is $day/$month/$y and time is $h-$min-$sec</p>\n"; print"</body>\n</html>\n";
|
|
CGI
Advantages of CGI
How CGI Works
Compiled Versus Interpreted
Input to CGI
CGI Introduction Program
HTML Forms
Accepting Input from the Browser
CGI Environment Variables
Get Versus Post Method
Get Method
Post Method
Sample <FORM> Based CGI Program
Complete Example for <FORM>
Output from CGI
Header and Body:Anatomy of Server Response
HTTP Headers
Carriage Returns and Newlines
Formatting Output CGI Common MIME TypesLocation Header Useful HTTP Stautus Codes Other Headers Dynamic Pages Sending Images Displaying the Current Date Feedback Form Program Server Side Includes Server Side Include Environment Variables Displaying the Date with Date Counter Example of SSI Counting the Number of Accesses Better Approach Towards CGI Program Client Versus Server Accessing a HTML Document Submitting a Form Accessing a CGI Program Databases ODBC Creating a DSN Win32::ODBC Module Creating a Table Inserting Data into a Table Deleting Data from a Table
Updating Data in a Table
Selecting Data from a Table Operating Systems Security Securing Your Web Server Writing Secure CGI ProgramWeb DesignDomain Names Home
FAQ
My Account
IP Address
SSL Certificates DNSWeb Hosting Web Server Cheap Web Design Dedicated web hosting Managed web hostingE Commerce Principles of E-Commerce E-Banking Electronic Payment System E-Security Credit Cards Smart Cards
The Mailbox POP Server SMTP Server IMAP Protocol |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |