View Full Version : How do I insert HTML code into formmail confirmation page?
stephenc
01-01-2003, 07:53 PM
I've just got formmail (which accesses sendmail on the host server) installed and set up, but I'm not happy with the confirmation page thats created following a message being sent. It simply states
"Thanks for your comments and feedback.
Please press the Back button on your browser."
The strange thing is that it allows the <p> paragraph tags.
I'd like it to be a bit more meaningfull and would like to put a HTML link back to the home page for example. But whenever I add anything more, it creates an error when the script runs.
Any help / thoughts would be appreciated. Code as follows -
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my ($to, $from, $subject, $contents);
print "Content-type:text/html\n\n";
#$to = param('to');
$from = param('from');
$subject = param('subject');
$contents = param('contents');
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
print MAIL "To: stephen\@sitedesigns4u.co.uk \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$contents\n";
close(MAIL);
print "Thanks for your comments and feedback. <p>Please press the Back button on your browser to return to the site.";
sub Error {
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
Grizz2
01-02-2003, 06:32 AM
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my ($to, $from, $subject, $contents);
print "Content-type:text/html\n\n";
#$to = param('to');
$from = param('from');
$subject = param('subject');
$contents = param('contents');
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
print MAIL "To: stephen\@sitedesigns4u.co.uk \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$contents\n";
close(MAIL);
print<<"PrintTag";
<html>
<head>
<title></title>
</head>
<body>
Create a whole html page if you want..
</body>
</html>
PrintTag
exit;
sub Error {
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
stephenc
01-02-2003, 11:53 AM
Hi Grizz
I've tried this code but it doesnt seem to want to work. I've created a test folder at -
http://www.sitedesigns4u.co.uk/cgi-bin/test/formmail.html
The script was working fine with the old 'Thanks for your comments and feedback.' but it wont accept the new tags. Any ideas?????? I can see the logic in your code but am baffled as to why it's creating the error.
I am getting the error message below -
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
:confused: :confused:
Grizz2
01-02-2003, 04:59 PM
First, make sure there are no spaces between these tags;
print<<"PrintTag";
<html>
This will usually cause an error:
print<<"PrintTag";
<html>
Same thing goes for the closing PrintTag;
</html>
PrintTag
Also make sure they(PrintTag) are spelled exactly the same and with same case. This can be any word, I just happen to use this one.
The closing PrintTag does not use a semi-colon. If you still get an error, copy and paste the script above and test as is. As far as your files, remember you are calling files from your cgi-bin so if you want to use an image in your page and normally would use "img src=pic.gif",, then you now would have to use "img src=../pic.gif" , same goes for links. This could be why your error page isn't found, depending on how it is set up.
stephenc
01-02-2003, 06:24 PM
Hi Grizz
Sorry, but its not working. The exact code is copied and pasted below. The paths must be ok because when I take out the HTML additional code, it works fine?
Stephen
CGI FILE CONTENTS -
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
my ($to, $from, $subject, $contents);
print "Content-type:text/html\n\n";
#$to = param('to');
$from = param('from');
$subject = param('subject');
$contents = param('contents');
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
print MAIL "To: stephen\@sitedesigns4u.co.uk \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$contents\n";
close(MAIL);
print<<"PrintTag";
<html>
<head>
<title></title>
</head>
<body>
Create a whole html page if you want..
</body>
</html>
PrintTag
exit;
sub Error {
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
HTML CONTENTS -
<HTML>
<HEAD>
<TITLE>Send e-mail to Stephen</TITLE>
</HEAD>
<BODY>
<FORM ACTION="http://www.sitedesigns4u.co.uk/cgi-bin/test/formmail.cgi" METHOD=POST>
<b><font size=+1>Write an email:</font></b>
<table border=0>
<tr><td align=right>To: </td><td><INPUT TYPE="text" NAME="to"></td></tr>
<tr><td align=right>From: </td><td><INPUT TYPE="text" NAME="from"></td></tr>
<tr><td align=right>Subject: </td><td><INPUT TYPE="text" NAME="subject"></td></tr>
<tr><td align=right>Contents: </td><td><TEXTAREA NAME="contents" ROWS=4 COLS=40></TEXTAREA></td></tr>
<tr><td> </td><td><INPUT TYPE="submit" VALUE="Send e-mail"> <INPUT TYPE="reset" VALUE="Erase e-mail"></td></tr>
</table></FORM>
</BODY>
</HTML>
:confused: :confused:
Grizz2
01-02-2003, 07:00 PM
I copy/pasted your script and did a test. The error was "String terminator PrintTag not found"
I removed hidden spaces before and after both "PrintTags" and the problem was solved.
So first place your cursor (I guess thats what its called) in front of <html> and back it up until its right against the first PrintTag, this will erase the spaces:
print<<"PrintTag";<html>
Then hit the enter key to put <html> back on the next line.
Do the same to eliminate spaces before and after the ending PrintTag
Give that a shot.
stephenc
01-02-2003, 07:23 PM
You guys are sooooooo good!
Many thanks Grizz, I was going round in circles and couldn't get a clue anywhere. Your suggestion solved the problem.
This is an excellent forum where I have found willing generous expert help.
Many thanks (again)
Stephen :) :thumbsup:
Grizz2
01-02-2003, 07:31 PM
No Problem..
Just a note. You can use anything between these tags that you might use in a regular html page, and you can also use your perl variables and arrays.
print<<"PrintTag";
<html>
<head>
<title></title>
</head>
<body>
Thanks. You submitted the following information<br>$contents
</body>
</html>
PrintTag
exit;
So, if you put an email address on this page you will have to backslash the @
for example <a href=mailto:me\@me.com>
stephenc
01-02-2003, 08:21 PM
It just keeps getting better .................
Stephen :o
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.