Solved

User input does not appear on my CGI program's response page

Posted on 1998-08-21
2
172 Views
Last Modified: 2013-12-25
I have a form to email program. Everything works except I can't seem to make the user's name (which is input through the form) appear on the CGI program's acknowledgement page to the user. The variable I used is called username. I  thought I could get the value of this by simply typing $username:

#within a sub-program
print "Content-type: text/html\n\n";
print<<"(ENDOFACK)";
<HTML>
<HEAD>
<TITLE>Acknowledgement</TITLE>
</HEAD>
<BODY>Thank you, $username!</BODY>
</HTML>
(ENDOFACK)


The response page that results is:

Thank you, !

Can someone help?
0
Comment
Question by:zgee
2 Comments
 
LVL 1

Accepted Solution

by:
RoboBob earned 10 total points
ID: 1828259
You probably arent defining $username anywhere, try this simple script, which should give you an idea what you need to do...

#!/usr/local/bin/perl -w
use CGI;

$cgi = new CGI;

print <<"END";
Content-Type: text/html

<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
END

if($cgi->param) {
    print "Thank you, ".$cgi->param('username')."!\n";
} else {
print <<"END";
<FORM METHOD=POST ACTION="$ENV{'SCRIPT_NAME'}">
Username: <INPUT TYPE=TEXT NAME=username><BR>
<INPUT TYPE=SUBMIT>
</FORM>
END
}

Also take a look at the CGI documentation ('perldoc CGI').
0
 

Author Comment

by:zgee
ID: 1828260
Thanks, Robobob. You were right. I missed out the definition of $username in my script.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question