$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))/eg; $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 ""; print "

User Is Added

"; print ""; }