Formatting Form Results

Hi Guys,

I am having sort of a difficult time figuring out a solid and quick method to format the results of online forms that i recieve in my email. Heres the scenario: I have a form on my website, user fills out the form and presses the submit button, the contents of the form are now routed to my email. I recieve the email and all the results of the form, are unformatted in a straight list ie.

[code]f_name = jim
l_name = bob
city = new york
state = NY

What I would like, is to recieve this email formatted so that it is much easier to read. There are a ton more fields than what i supplied above, so you can only imagine with about 30 fields of information, its quite confusing to view all the results. Ideally, i want the form formatted so i can just print the entire page out, and it will look as if the person filled out the form online, printed it and handed it to me.
I was told that there is a method, in which i can create a format in notepad and call it within the code, so that the email i recieve follows the format of the notepad file. Ive looked online, to no avail. I would more rather not go the asp or other language route, but if that is the only method, i would gladly listen to tips or visit online tutorials.
If anyone has any thoughts or tips, or know of a place where i can learn more about this, please post here or email me at I appreciate the help in advance. Thank you Guys.


  • Hi,

    The server side method is the only reliable way of doing this that I know of. Writing a form mail script is fairly easy provided you are careful not to open up a SPAM hole. Here's one I can quickly hack together in Perl:-


    #Get form data.
    my @pairs = ();
    my %formdata = ();
    if ($ENV{'REQUEST_METHOD'} eq 'GET') {
    @pairs = split(/&/, $ENV{'QUERY_STRING'});
    } else {
    read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach my $pair (@pairs) {
    my ($key, $value) = split (/=/, $pair);
    $key =~ tr/+/ /;
    $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    if ($formdata{$key}) {
    $formdata{$key} .= ", $value";
    } else {
    $formdata{$key} = $value;

    #Open sendmail program.
    open my $mail, "| /usr/bin/sendmail";

    #Put your email address below.
    print $mail "To:
    print $mail "From: $formdata{'email'}
    print $mail "Subject: Form Submission


    #Here's the message...between the qq{ and the }.
    print qq{Put your message in here.

    If you want to display a form field, put
    $formdata{'filedname'} where fieldname is the
    name of the fied in a form. You can format the
    message quite well like this.

    }; # Do NOT miss this line at the end of the message!
    close $mail;

    #Replace the address below with the page a user should go
    #to after the form is submitted.
    print "Location:


    That'll run on the vast majority of Linux/UNIX boxes and is fairly safe so long as you don't use a form variable in the too address. When you do that, you create a SPAM script and you'll be the blame for other people abusing it.

    Hope this helps,


    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion