Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How are my form values passed into perl?

How are my form values passed into perl?
Thread Tools
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Jun 13, 2003, 10:54 AM
 
Let's say I have a form with two fields.

name=first_name
name=last_name

I enter John Smith into the two fields/

i have a script that runs called do_something.cgi

how does do_something.cgi get ahold of the values in my form?

is it in a hash? if so what is the name of the hash?

are they just variables?

i'm not too got at cgi.pm (yet), so if you could show me how to do it without that module that would be great.
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jun 13, 2003, 03:31 PM
 
in your form you specify method and action

method is either 'get' or 'post'
if it is get it shows up in the url line (something.cgi?name=xyz)

with post it gets sent to the cgi script through stdin

action is where it sends to, in this case your cgi script

in cgi you can find what has been sent fairly easily

Code:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; }
that sample is for post (notice the read STDIN)

search google for form parsing in perl for more examples

--will
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:42 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2