Solved

Form processing.

Posted on 2000-05-10
5
150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now