Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Assistance

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
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
 
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
 
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=&quot;hcwhite\@hotmail.com&quot;;
open(MAIL, &quot;|/var/qmail/bin/qmail-inject -t $to&quot;) || die
(&quot;can't open sendmail&quot;);
print MAIL &quot;From: $FORM{'email'}\n&quot;;
print MAIL &quot;To: $to\n&quot;;
print MAIL &quot;Subject: Form submission\n\n&quot;;
# print out the form results
print MAIL &quot;Name: $FORM{'Name1'}\n&quot;;
# print MAIl &quot;Title: $FORM{'Title'}\n&quot;;
print MAIl &quot;Title: $FORM{'Title'}\n&quot;;
# print MAIL &quot;E-mail: $FORM{'Email'}\n&quot;;
print MAIL &quot;E-mail: $FORM{'Email'}\n&quot;;
# print MAIL &quot;Address: $FORM{'Address'}\n&quot;;
print MAIL &quot;Address: $FORM{'Address'}\n&quot;;
# print MAIL &quot;Gender: $FORM{'Gender'}\n&quot;;
print MAIL &quot;Gender: $FORM{'Gender'}\n&quot;;
#print MAIL &quot;Age: $FORM{'Age'}\n&quot;;
print MAIL &quot;Age: $FORM{'Age'}\n&quot;;
# print MAIL &quot;Date of Birth: $FORM{'DOB'}\n&quot;;
print MAIL &quot;Date of Birth: $FORM{'DOB'}\n&quot;;
#print MAIL &quot;How did you find out about Harmani?: $FORM{'Info1'}\n&quot;;
print MAIL &quot;How did you find out about Harmani?: $FORM{'info1'}\n&quot;;
#print MAIL &quot;What is it that you like about Harmani?: $FORM{'Info2'}\n&quot;;
print MAIL &quot;What is it that you like about Harmani?: $FORM{'info2'}\n&quot;;
#print MAIL &quot;What would you like to see improved at Harmani?: $FORM{'Comment'}\n&quot;;
print MAIL &quot;What would you like to see improved at Harmani?: $FORM{'Comment'}&quot;;
close (MAIL);
}
sub print_thankyou_page
{
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n<HEAD>\n<BODY BGCOLOR=\&quot;#FFFF99\&quot;>\n</HEAD>&quot;;
print &quot;<H3>Thank You</H3>\n\n&quot;;
print &quot;<P>\n&quot;;
print &quot;Thank you for your submission. We at Harmani will respond to you shortly.\n&quot;;
print &quot;<P>\n&quot;;
print &quot;<A HREF=\&quot; To Main Page</A>\n&quot;;
}
print &quot;</BODY<\n</HTML>&quot;;
 
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
 
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.
 
Ditto - I don't understand the question, yet.


keep the rudder amid ship and beware the odd typo
 
Hey All,

Thanks for responding. The form that I'm currently using is located at
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
 
try the following script:

#!/usr/local/bin/perl

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

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


$Comments = $FORM{'Comments'};



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

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





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

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


close(MAIL);


exit;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top