Important alert: (current site time 7/15/2013 8:49:43 PM EDT)
 

VB icon

A better form data retriever

Email
Submitted on: 1/27/2001 10:47:30 AM
By: Leow KM 
Level: Beginner
User Rating: By 1 Users
Compatibility: 5.0 (all versions)
Views: 13546
 
     Retrieves form submission contents and store them into a hash (%FORM). Though there are other similar codes that could do the same function as this, this code is slightly better because it uses some private variables.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
=**************************************
= for :A better form data retriever
=**************************************
Feel free to distribute it as long as you keep
the comment line in the first line of my code.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: A better form data retriever
= Description:Retrieves form submission contents and store them
into a hash (%FORM). Though there are other
similar codes that could do the same function as
this, this code is slightly better because it
uses some private variables.
= By: Leow KM
=
= Inputs:Accept inputs from form through GET and POST method.
=
= Returns:Stores all form data retrieved into a hash to allow the user to manipulate the data.
=
= Assumes:If you know what is a form in HTML, then you should know the purpose of this code. If you still
do not know how to use this, feel free to ask me.
=
= Side Effects:None that I know.
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=158&lngWId=6=for details.=**************************************

#A much better form data retriever by Leow Kah Man (kmleow@bigfoot.com)
if ($ENV{'REQUEST_METHOD'} eq "GET") {
	$formdata = $ENV{'QUERY_STRING'};
} else { read(STDIN,$formdata,$ENV{'CONTENT_LENGTH'}); }
$buffer =~ s/\+/ /g;
foreach my $pair (split(/&/,$formdata)) {
	my($name,$value) = split(/=/,$pair);
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
	$FORM{$name} = $value;
}


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

1/30/2001 7:50:12 AMPaC

why use this when there is standard module that is distro'd with perl.

use CGI qw/:standard/;
$myparam=param('someparam');

myscript.pl?someparam=hey

$ myparam
now has the value of hey
(If this comment was disrespectful, please report it.)

 
2/5/2001 10:01:56 AMSam Land

I think its a great submission. To build a complete code libary!!!!!! Thanks for the code Leow Kah Man
(If this comment was disrespectful, please report it.)

 
6/24/2002 4:28:57 PMMeeco

My new Email is "Clinteastwood@aol.com,

leo, if you would to start posting your codes at another site, try, vbheaven.com, we are trying to get the perl section moving on the forums, your welcome to it =D thankz :D
(If this comment was disrespectful, please report it.)

 
4/13/2003 6:16:45 AMJohn Manavalan

plz how can i print values from from.............plz reply
(If this comment was disrespectful, please report it.)

 
4/13/2003 10:55:55 AMLeow Kah Man

Usage details:
All data is stored in $FORM hashtable.
so $FORM{''} returns the value you need.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.