?
Solved

form processing

Posted on 1998-02-03
1
Medium Priority
?
182 Views
Last Modified: 2013-12-25
I want to process some forms online using CGI and send
the contents of the form to a data store e.g. text file

Is it possible to store the data in that file as they appear
in the form.
0
Comment
Question by:aswad012698
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
joseph4 earned 120 total points
ID: 1831914
in order to filter out any input you *don't* want to record (such as "method=post") have the name of each input field you *do* want begin with "store" followed by a number to control the order in which they are written to the file. for example,
<input type="text" name="store1Name">
<input type="text" name="store2EmailAddress">
<input type="text" name="store3Handle">

the script:

#!/usr/local/bin/perl

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

&GetInput($buffer);

unless (open (STOREDDATA, '>>' . 'stored_data_file.txt')){
print "unable to open file";
exit;
}

foreach $key (sort keys(%FORM)) {
next unless($key =~ /^store/);
print STOREDDATA $FORM{$key};
}

print STOREDDATA "----------";

close(STOREDDATA);

##
sub GetInput
{
    $ParseWhat = $_[0];
    @forminput = split(/&/, $ParseWhat);
    foreach (@forminput)
    {
        tr/+/ /;
        ($name, $value) = split(/=/, $_);
        $value =~ s/%(..)/pack("C", hex($1))/eg;
        $FORM{$name}=$value;
    }
}



file will look like this:

name
email
handle
-------
name
email
handle
-------
etc.
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

800 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