RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Perl - CGI - form submit example

The following Perl/CGI form example asks a user to enter two integers and upon the submission an addition is performed on both submitted integers.

Note: to handle both integers the "post" method action is set to itself. Meaning that a HTML post method will be created in a following format:

form action="/cgi-bin/perl-cgi-form.cgi" enctype="multipart/form-data" method="post"

Save a following perl-cgi-form.cgi code into /usr/lib/cgi-bin/:

#!/usr/bin/perl -T 
use strict; 
use CGI qw/:standard/; 
print header, 
start_html('Perl/CGI form example'), 
start_form, 
	"Integer 1: ",textfield('num1'), 
	br, 
	"Integer 2: ",textfield('num2'), 
	br, 
	submit, 
end_form, 
hr; 
 
print param('num1')+param('num2'), 
	p, 
	end_html; 
exit; 

make it executable:

# chmod 755 /usr/lib/cgi-bin/perl-cgi-form.cgi

by navigating your browser to the above Perl/CGI program you should see a page similar to the one below. Currently the form can handle only integers:

PERL CGI FORM example

Share this linux post:

Submit Perl - CGI - form submit example in Delicious Submit Perl - CGI - form submit example in Digg Submit Perl - CGI - form submit example in FaceBook Submit Perl - CGI - form submit example in Google Bookmarks Submit Perl - CGI - form submit example in Stumbleupon Submit Perl - CGI - form submit example in Technorati Submit Perl - CGI - form submit example in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download