Solved

Form processing.

Posted on 2000-05-10
5
153 Views
Last Modified: 2013-12-25
I've got a homepage where users can fill in 2 forms. How can I process the data that the user filled in at these forms. (The forms are created by html code). I know how to program in cgi, but I don't know how I can extract the form-data if the cgi-script has been called. Hope someone can help me out...
0
Comment
Question by:oostwijk
5 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2797468
here is a simple solution using PERL and CGI.

==========form1.html
<form method=post action=/cgi-bin/form1.pl>
<input type=text name=name><BR>
<select name=type>
<option value=".123">123
<option value=".345">345
<option value=".075">075
</select>
<P>
<input type=submit>
</form>


==========form1.pl
#!/usr/local/bin/perl

use CGI;

$q=new CGI;

##  Read the users input values.
$name=$q->param('name');
$type=$q->param('type');

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

print qq {
  <B>You selected.... </B><P>
  Name: $name<BR>
  Type: $type<BR>
  <HR>
};


hope that helps
0
 

Accepted Solution

by:
noleaders earned 50 total points
ID: 2809353


   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 5) {
         $buffer = $ENV{QUERY_STRING};
    }
 
  @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;
   }

$action = $FORM{'action'};

This parses the input of any value of your form... If your form field name is called: Question1 the variable to call the data inputed to that field is:

$FORM{'Question1'}

Hope that does it!
0
 

Expert Comment

by:kurman
ID: 2809622
use wwwlib.pl
this gives you simplified access to both POST and query.
Only things you need to specify is the input- and the text or option
button names etc.
0
 
LVL 7

Expert Comment

by:ssdesign
ID: 2810677
go to

http://cgi.resourceindex.com/Programs_and_Scripts/Perl

You will find lots of scripts that will do the job for you.
0
 

Author Comment

by:oostwijk
ID: 2818488
That does the job...
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question