Solved

Form processing.

Posted on 2000-05-10
5
149 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
Comment Utility
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
Comment Utility


   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
Comment Utility
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
Comment Utility
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
Comment Utility
That does the job...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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 …

771 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

11 Experts available now in Live!

Get 1:1 Help Now