[ back to toc ]

Perl-CGI-HTML

Date: 2002/03/14 09:50

Q:
I am a student and stuck with my assignment.
The assignment (part of it) is:
1. Create HTML file with a Form in it. One data is "myname".
2. Send it to the first *****.cgi file. This file should print out the
data from the form (smth like "your name is $myname"). This cgi file
contains another new Form with a "hidden" field. Put the name that you
received from HTML file into a "hidden" field and send it to the second
*****.cgi file.
3. The second cgi file should receive the value of $myname.
My questions are: 1.How to send the value of "myname" from the first to
the second cgi script. 2. How to print in the second cgi file smth like
"your name is $myname" (Is it possible?). 3. How to do smth like "if
(myname=John) print "Hello" else print "Good-buy"". CGI's are done in
Perl. I work on UNIX-Solaris.
Thank you very much.
A:
Creating the HTML form should be simple for you I assume. The first CGI
processes the form data, which I aslo assume you can do. The first.cgi
prints an HTML page that contains the name. This is simply a print
statement. However the printed page also contains a form that addresses
second.cgi as "action", like:

print <<<FORM;
<form action"second.cgi" method="post">
<input type="hidden" name="name" value="$myname">
<input type="submit">
</form>
FORM

assumed that the Perl variable $myname already contains the name received
from submitting the form. The second CGI gets this hidden field when the
user presses the submit button.

I hope this clarifies the issue.

Regards,
Peter

[ back to toc ]