Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
Web Design
Televisions
Promotional Golf
Web Hosting Directory
Hurricane Shutters
Promotional Products
KVM Switch over IP
Promote Your Website
Phone Cards
Home Improvement
Promotional Pens
Auto Insurance Quote
Laptop Batteries
Car Donations

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


  eKit: Essential HP Solutions for Your Data Center
Data protection and disaster recovery tools help keep data secure and available under the worst of circumstances.

Download this eKit and get:

eBook: Guide to Storage Networking
eBook: Storage Networking 2, Configuration and Planning
Whitepaper: Storage Management Costs in the Enterprise: A Comparison of Mid-Range Array Solutions
Whitepaper: Virtualization - It's Not Just for Enterprises Anymore
Whitepaper: Continuous Real-time Data Protection and Disaster Recovery

Click Here!
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

CGI: Input

CGI scripts get their input mainly from environment variables and standard input (when using the POST method). These environment variables are set when the server executes the gateway program.

The environment variable QUERY_STRING is everything that follows the question mark in the URL. This information could be added either by an ISINDEX document, or by a form using the GET method.

In the POST method, form data are read from stdin. The server will NOT send you an EOF on the end of the data, instead you should use the environment variable CONTENT_LENGTH to determine how much data you should read from stdin.

	$method = $ENV{'REQUEST_METHOD'};

#	Get the query string, & decode it.

	if	( $method eq 'POST' )	{

#		The POST method means that the form data
#		are coming in through standard input.

	 	read(STDIN, $_, $ENV{'CONTENT_LENGTH'});
		}
	elsif	( $method eq 'GET' )	{

#		The GET method means that the form data
#		are coming in through an environment
#		variable.

		$_ = $ENV{'QUERY_STRING'};
		}
	else	{
		print	"UnExpected method:	$method";
		exit	(1);
		}
#	Data have been presented as text between
#	ampersands, in the form name=value

	foreach $_	(split(/&/))	{

#		This string is encoded in the standard
#		format of changing spaces to +, and
#		encoding special characters with %xx
#		hexadecimal encoding.

		# Convert plus's to spaces
		$in[$i] =~ s/\+/ /g;

		# Split into key and value.
		($key, $val) = split(/=/,$in[$i],2);
				  
		# Convert %XX from hex numbers to
		#	alphanumeric
		$key =~ s/%(..)/pack("c",hex($1))/ge;
		$val =~ s/%(..)/pack("c",hex($1))/ge;

		# Associate key and value
		$in{$key} .= "\0" if (defined($in{$key})); 
		$in{$key} .= $val;
		}

Note that the last 2 lines of code append values having the same name. This may happen, for example, when the HTML form contains multiple OPTIONs in a SELECT tag, and the user selected more than one. Or when the user selects multiple radio buttons. Or when some of the form elements have the same name (unusual, but not impossible). So the script will have to know about these cases, and separate out multiple values, e.g. using split('\0').

Normally you will not write code such as the above into every CGI program, but use one of the libraries. A very common approach is to use ReadParse from cgi-lib.pl. Let us suppose we wanted to echo the values selected from the following form:

The following code is a (barebones) way to do it:
#!/bin/perl
require	'/home/web/public_html/Software/Perl/cgi-lib.pl';

	&ReadParse	;

	print	"Content-type: text/html\n\n";

	foreach	(split('\0',$in{'options'}))	{
		print	"$_\n";
		}


Up to => Home / Authoring / CGI




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers