Forum Moderators: phranque

Message Too Old, No Replies

Looking for a good form processor

Need something that's secure, easy to set up

         

MatthewHSE

12:38 am on Oct 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I may be looking for the Fountain of Youth here, but does anyone know of a good, secure, form processing script that will write form results to another file? Here are the features I need:

- Write form results to a comma-delimited text file

- The data in the text file needs to be secure so no unauthorized prying eyes can get at it.

- Easy to set up. I've tried a few that were pretty complex.

- Hopefully free (I'm on a limited budget!)

I'm not particular if the script is PERL or PHP, just so it works.

Does anyone have any suggestions?

Thanks,

Matthew

txbakers

4:23 am on Oct 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Everything you ask for is easy to do in most any language, except the secure text file part.

You can protect the directory so no one can download it, but you will be able to read it, and if it is going across the internet, it won't be secure unless you route it through an HTTPS uri.

I suppose you can encrypt the data as it is being written by running it through an excryption subroutine.

MonkeeSage

8:20 am on Oct 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP:

<?php 

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$_FORM = $_POST;
}
else {
$_FORM = $_GET;
}

foreach ($_FORM as $key => $value) {
if ($key!= $value) {
$value = str_replace("''", "'", $value);
$value = str_replace("+", " ", $value);
$value = str_replace(",", "", $value);
filewrite ("$key,$value\n");
}
}

function filewrite ($toWrite) {
$fp = fopen ("../file.ext", "a");
fwrite ($fp, $toWrite, strlen ($toWrite));
fclose ($fp);
}

?>

--------

Perl:

#!/usr/bin/perl 
use strict;
use warnings;

my $buffer;
my %FORM;

print "Content-type: text/html\n\n";

if ($ENV{'REQUEST_METHOD'} =~ /POST/i) {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else {
$buffer = $ENV{'QUERY_STRING'};
}

my @pairs = split(/&/, $buffer);
foreach my $pair (@pairs) {
my($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\'\'/\'/g;
$value =~ s/\,//g;
$FORM{$name} = $value;
}

foreach my $key (keys(%FORM)) {
&filewrite("$key,$FORM{$key}\n");
}

sub filewrite {
my $toWrite = shift;
open(OUTF,">>../file.ext");
seek(OUTF, 0, 2);
print OUTF "$toWrite";
close(OUTF);
}

exit 1;

HTH
Jordan