Web guru's i need some help please...

kellygtp

New Member
Joined
May 21, 2006
ok so i made a webpage for a friend of mine ( very siomple and to the point page) and i have a form mailler provided by godaddy.com on thier hiosting plan however i dont know php or cgi scripting very well and i need help...

1. the email sent out fromt eh cgi script is in alphebatical order, if someone php and cgi savy could look at the code an tell me what to edit to make it sent as it is filled out that would be great.

2. every space in the form has a + in it....meaning a space=+ so it come out like this
First+Name: and not First Name: so i need to know how to change that as well....any help would be awsome guys and girls....thanks


PHP code
<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");

$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}


?>



CGI SCRIPT

#!/usr/bin/perl

sub parse_form_data
{
local (*FORM_DATA) = @_;
local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value);
$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
};
@key_value_pairs = split(/&/, $query_string);
foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
if (defined($value)) {$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;};
if (defined($FORM_DATA{$key})) {
$FORM_DATA{$key} = join (" ", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
}
}
}; # end of sub

&parse_form_data(*simple_form);
$t = time;
chdir ($ENV{'DOCUMENT_ROOT'}) ; chdir("..");
open (OUTFILE, ">data/gdform_$t") or die ("Cannot open file");
while (($key , $value) = each(%simple_form)) {

print OUTFILE "<GDFORM_VARIABLE NAME=$key START>\n";
print OUTFILE "$value\n";
print OUTFILE "<GDFORM_VARIABLE NAME=$key END>\n";
if ($key eq "redirect") { $landing_page = $value;}

}
close (OUTFILE);
if ($landing_page ne "") {
print "Location: http://$ENV{'HTTP_HOST'}/$landing_page\n\n";
} else {
print "Location: http://$ENV{'HTTP_HOST'}/\n\n";
}
 
Top