User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 427,223 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,272 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 719 | Replies: 3
Reply
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation: kahaj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Form processing problem

  #1  
Jul 3rd, 2008
I'm trying to get an email generated when a form is processed. This is my first stab at such. It's not working for some reason. When I comment out the lines concerning the email generation, it works fine. The problem apparently lies somewhere in that section of the code, but I'm not sure just what the issue is.

#!/usr/bin/perl 
#trialSubscription.cgi


print "Content-type: text/html\n\n";
use CGI qw(:standard);
use Mail::Sendmail;
use strict;


#var declarations
my ($firstName, $lastName, $email, $street, $city, $state, $zip, $msg, %mail);


#var values
$firstName = param('firstName');
$lastName = param('lastName');
$email = param('email');
$street = param('street');
$city = param('city');
$state = param('state');
$zip = param('zip');


#create message to email
$msg = "$firstName $lastName would like to subscribe to a free 6 month trial of SGN Scoops.  His/her email address is $email. \n";
$msg = $msg . "The physical address is $street in $city, $state $zip.";


#create page
print <<endHtml;
<html>
<head>
<title>Thank you for subscribing</title>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center" /><font size="4" face="Arial">Thank you for subscribing, $firstName.<br />
Click <a href="index.html">here</a> to return to the SGN Scoops main page.</font></p>
</body>
</html>
endHtml


#send email
$mail{To} = 'kahaj@yahoo.com';
$mail{From} = $email;
$mail{Subject} = 'Trial Subscription Request';
$mail{Smtp} = 'mail.sgnscoops.com';
$mail{Message} = $msg;
sendmail(%mail);
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation: kahaj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Re: Form processing problem

  #2  
Jul 10th, 2008
In my previous post, I used an example from a text book. I've scoured the web and found various reccomendations on how to accomplish my goal. I've tried the following only to end up with a 500 error still. Any tips with this would be fantastic.

#!/usr/bin/perl 
#trialSubscription.cgi


use CGI qw(:standard);
use Mail::Sendmail;
use strict;


#var declarations
my ($firstName, $lastName, $email, $street, $city, $state, $zip, $msg, %mail);


#var values
$firstName = param('firstName');
$lastName = param('lastName');
$email = param('email');
$street = param('street');
$city = param('city');
$state = param('state');
$zip = param('zip');


#send email
open (MESSAGE,"| /usr/sbin/sendmail -t");
	print MESSAGE "To: kahaj\@yahoo.com\n";
	print MESSAGE "From: sgnscoops.com", reader\n";
	print MESSAGE "Subject: Trial Subscription Request \n\n";
	print MESSAGE "$firstName $lastName\n\n";
	print MESSAGE "$email\n\n";
	print MESSAGE "$street\n";
	print MESSAGE "$city, $state  $zip\n\n";
close MESSAGE;


#create page
print <<endHtml;
<html>
<head>
<title>Thank you for subscribing</title>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center" /><font size="4" face="Arial">Thank you for subscribing to our free trial offer, $firstName.<br />
We hope that you enjoy the all-new SGN Scoops!<br />
Click <a href="index.html">here</a> to return to the SGN Scoops main page.</font></p>
</body>
</html>
endHtml
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Reply With Quote  
Join Date: Mar 2006
Posts: 620
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Form processing problem

  #3  
Jul 10th, 2008
replace these lines:

#create page
print <<endHtml;

replace with:

#create page
print header;
print <<endHtml;

"header" is a function of the CGI modules ":standard" functions and will print the http header which is required before printing anything else to the browser. I could have sworn I already told you that on another forum but maybe I am confused.
Last edited by KevinADC : Jul 10th, 2008 at 7:58 pm.
Reply With Quote  
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation: kahaj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Re: Form processing problem

  #4  
Jul 12th, 2008
If you did, I certainly don't recall it, but I won't swear that you didn't. At any rate, I changed that and it still says the same thing. My server's error log does say this:
"Premature end of script headers: /home/.../public_html/cgi-bin/trialSubscription.cgi"

I'm doing some research to see what could cause this, but I'm finding a lot of different tips. I'm going to start trying them one by one to see how it goes (or how it doesn't go).
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 11:31 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC