Thread: CGI and Form

    #1
  1. SwollenMember
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    the master control
    Posts
    264
    Rep Power
    15
    What is the simplest way to enter data into a single field, then have another page come up with it's output(ie one html page that calls a cgi script). I want it to print out the data unparsed.
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    ##form.html##
    <html>
    <body>
    <form method="POST" action="/cgi-bin/script.pl">
    <input type="text" name="email"><br>
    <input type="submit" value="submit">
    </form>
    </body>
    </html>

    ##script.pl##
    #!/usr/local/bin/perl
    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;
    $value =~ s/<!--(.|n)*-->//g;
    $value =~ s/<([^>]|n)*>//g;
    $FORM{$name} = $value;
    }
    print "Content-type: text/htmlnn";
    if ($FORM{'email'} eq "") {
    print "Blank field!n";
    }
    else {
    print "$FORM{'email'}n";
    }
    exit;
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    16
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by tron:
    What is the simplest way to enter data into a single field, then have another page come up with it's output(ie one html page that calls a cgi script). I want it to print out the data unparsed.[/quote]

    Well, whatever you do, don't start reinventing the wheel. Spend the time and sweat to understand the following:
    http://stein.cshl.org/WWW/software/CGI/

    Peter
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    USA
    Posts
    67
    Rep Power
    15
    this would print out the entire data being sent, unparsed.


    #!/usr/local/bin/perl

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


IMN logo majestic logo threadwatch logo seochat tools logo