×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need Assistance

Need Assistance

Need Assistance

(OP)
Hi All,

I successfully created a form and cgi script a few days ago for the first time (with the help of goboating of course). However, when I type data/information into my form and hit submit, the only thing that appears in my e-mail is the print command data

For example,

print MAIL "Date of Birth: $FORM{'DOB'}\n;
 
Can someone please help? It would be greatly appreciated.

shake & bake

RE: Need Assistance

Well the reasons could depend on many items, how are you getting the form information from the content_length environment to the hash FORM?

-Blake

RE: Need Assistance

(OP)
Hi Payload,

This is my script. Hope this answers your question.

shake &  bake

Please help.


#!/usr/local/bin/perl
&get_form_data();
&send_email;
&print_thankyou_page;
sub get_form_data
{
#Get the input
read(STDIN, $buffer,$ENV{'Content_Length'} );
#Split the name-value pairs
@parirs=split(/&/, $buffer);
foreach $pair (@paris)
    {
    ($name, $value)=split(/=/, $pair);
    #Un-Webify plus signs and %-encoding
    $value=~tr/+/ /;
    # $value=~s/%[a-fA-F0-9][a-fA-F0-9])/pack("C",hex($!))/eg;
    $value=~s/%[a-fA-F0-9][a-fA-F0-9]/pack("C",
    hex($!))/eg;
    $value=~s/<!--(.|\n)*-->//g;
    # $FORM{$name}=$value;
    $FORM{$name}=$value;
    }
}
sub send_email
{
$to="hcwhite\@hotmail.com";
open(MAIL, "|/var/qmail/bin/qmail-inject -t $to") || die
    ("can't open sendmail");
print MAIL "From: $FORM{'email'}\n";
print MAIL "To: $to\n";
print MAIL "Subject: Form submission\n\n";
# print out the form results
print MAIL "Name: $FORM{'Name1'}\n";
# print MAIl "Title: $FORM{'Title'}\n";
print MAIl "Title: $FORM{'Title'}\n";
# print MAIL "E-mail: $FORM{'Email'}\n";
print MAIL "E-mail: $FORM{'Email'}\n";
# print MAIL "Address: $FORM{'Address'}\n";
print MAIL "Address: $FORM{'Address'}\n";
# print MAIL "Gender: $FORM{'Gender'}\n";
print MAIL "Gender: $FORM{'Gender'}\n";
#print MAIL "Age: $FORM{'Age'}\n";
print MAIL "Age: $FORM{'Age'}\n";
# print MAIL "Date of Birth: $FORM{'DOB'}\n";
print MAIL "Date of Birth: $FORM{'DOB'}\n";
#print MAIL "How did you find out about Harmani?: $FORM{'Info1'}\n";
print MAIL "How did you find out about Harmani?: $FORM{'info1'}\n";
#print MAIL "What is it that you like about Harmani?: $FORM{'Info2'}\n";
print MAIL "What is it that you like about Harmani?: $FORM{'info2'}\n";
#print MAIL "What would you like to see improved at Harmani?: $FORM{'Comment'}\n";
print MAIL "What would you like to see improved at Harmani?: $FORM{'Comment'}";
close (MAIL);
}
sub print_thankyou_page
{
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<BODY BGCOLOR=\"#FFFF99\">\n</HEAD>";
print "<H3>Thank You</H3>\n\n";
print "<P>\n";
print "Thank you for your submission. We at Harmani will respond to you shortly.\n";
print "<P>\n";
print "<A HREF=\"http://www.harmani.com/glance.html\";>Return To Main Page</A>\n";
}
print "</BODY<\n</HTML>";

RE: Need Assistance

(OP)
Hey All,

I know your busy, but if someone could help, I would greatly appreciate it. I still need help with solving the above.



shake & bake

RE: Need Assistance

Shake and Bake -- I'm sorry, I don't understand you. What is missing from the email?

Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.

RE: Need Assistance

Ditto - I don't understand the question, yet.


 
 
 keep the rudder amid ship and beware the odd typo

RE: Need Assistance

Shake and Bake, can you post the actual form that is collecting and submitting the data that get_form_data is accepting?


Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

RE: Need Assistance

(OP)
Hey All,

Thanks for responding. The form that I'm currently using is located at http://www.harmani.com/feedback/form.html

When I type data into the form, and then press submit, the form appears to be working fine--that is, I receive a thank you for your submission response, and that someone will reply to me soon. Yet, when the form's e-mail is sent to me, there is no data included. The only thing that appears is the following:

Name:
E-mail:
Address:
Gender:
Age:  
Date of Birth:
How did you find out about Harmani?:
What is it that you like about Harmani?:
What would you like to see improved at Harmani?:

Can anyone help?

shake & bake

RE: Need Assistance

try the following script:

#!/usr/local/bin/perl

################ DECODE THE FORM INPUT
################################################
if ($ENV{'REQUEST_METHOD'} eq "POST")
  { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }

@nvpairs = split(/&/, $buffer);
foreach $pair (@nvpairs)
 {
        $pair =~ tr/+/ /;
        $pair  =~ s/%(..)/pack("c",hex($1))/ge;
        ($name, $value) = split(/=/, $pair, 2);
        $FORM{$name} = $value;
        $value =~ tr/\n/   /;
        $value =~ tr/\r/   /;
        $value =~ tr/\"/\'/;
        $value =~ tr/,/\;/;
        push(@values, qq/"$value"/);
        push(@email, qq/$name=$value/);
 }


$Comments = $FORM{'Comments'};



################ SET THE VARIABLES
################################################

$mail = "/bin/mail";
$mail_to = "sth\@sth.com";





################ NOTIFY THE DEPARTMENT
################################################

open(MAIL , "| $mail -s \"Complaints Form For sth.com.\" $mail_to");
print MAIL "COMPLAINS SUBMISSION FORM\n\n";
print MAIL "----------------------------------------------------------------------------------------\n";
print MAIL "$Comments\n";
print MAIL "----------------------------------------------------------------------------------------\n";


close(MAIL);


exit;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close