Forum Moderators: coopster & phranque

Message Too Old, No Replies

displaying form data in perl thankyou page

         

daphreephunkateer

5:27 pm on Mar 7, 2004 (gmt 0)

10+ Year Member



i'm using cgi and perl for an order form.

cgi script emails info to me in the normal way.

once someone makes an order, they are taken to a thankyou page. can i display the details of their order on this thankyou page? if so, how?

could any1 give me an eg?

cheers in advance...

Hissingsid

8:55 am on Mar 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

This may be the blind leading the blind, but here goes. This is how I would go about it in very simple terms. First make a backup of your current script.

Open your script in a text editor. Then select and copy the print lines from the email sending subroutine, it probably looks something like this.

sub send_mail {
# Open The Mail Program
open(MAIL,"¦$mailprog");

print MAIL "To: bob\@yourdomain.com\n";
print MAIL "From: $Email ($Name)\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Message: $Message\n";

close (MAIL);
}

Find the subroutine that takes the user to the thank you screen. This could be a line by line print statement or a here print statement. If it is a here print statement you can paste in the email print sub and delete the stuff that you don't need from that sub just leaving the labels and variables. Use whatever formatting you want. It will then look something like this, much simplified for clarity.

#This prints until it finds the next occurance of EOF
print <<"EOF";

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Thanks for the message</title>
</head>
<body>

LOTS OF html CODE

<p> Thank you for your message. <br />
Here is a summary of what you sent<br />

To: bob\@yourdomain.com<br />
From: $Email ($Name)<br />
Subject: $subject<br />
Message: $Message<br /></p>

LOTS MORE html CODE

</body>

EOF

If the script that you are using prints each line of the like this

print "some text in here";

Then you need to find a relevant spot in it and paste in your email code there like this.

print MAIL "To: bob\@yourdomain.com\n";
print MAIL "From: $Email ($Name)\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Message: $Message\n";

Now just deleat MAIL from each line and change those newlines \n for HTML <br /> so it looks like this:

print "To: bob\@yourdomain.com<br />";
print "From: $Email ($Name)<br />";
print "Subject: $subject<br /><br />";
print "Message: $Message<br />";

In either case your thanks sub should now add a user specific message to the thanks page.

I hope that this helps. I'm still a newbie after more than two years of doing a bit of Perl scripting so perhaps others will have an easier way of doing this but I doubt it.

Best wishes

Sid