ckluver has asked for the wisdom of the Perl Monks concerning the following question:
$UserDB = "datahere/UserDB.txt"; print "Content-type: text/html\n\n"; # Parse Form Contents &parse_form; # Add to user database &add_db; # display results &results; sub parse_form { if ($ENV{'REQUEST_METHOD'} eq 'GET') { # Split the name-value pairs @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @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))/e +g; $Form{$name} = $value; } } sub add_db { open (FILE,">>$UserDB"); print FILE "$Form{'companycode'}\t"; print FILE "$Form{'password'}\t"; print FILE "\t\n"; close(FILE); } sub results { print "<html>"; print "<p>User Is Added</p>"; print "</html>"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get Form Data/Write to Text File
by Joost (Canon) on Jun 04, 2007 at 19:42 UTC | |
|
Re: Get Form Data/Write to Text File
by FunkyMonk (Bishop) on Jun 04, 2007 at 19:39 UTC | |
by GrandFather (Saint) on Jun 05, 2007 at 03:43 UTC | |
by Anonymous Monk on Jun 05, 2007 at 08:38 UTC | |
|
Re: Get Form Data/Write to Text File
by bradcathey (Prior) on Jun 05, 2007 at 01:25 UTC | |
|
Re: Get Form Data/Write to Text File
by perlfan (Parson) on Jun 04, 2007 at 19:40 UTC | |
|
Re: Get Form Data/Write to Text File
by naikonta (Curate) on Jun 05, 2007 at 06:28 UTC | |
by ckluver (Initiate) on Jun 08, 2007 at 20:23 UTC |