Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input-Output with Perl and HTML

Status
Not open for further replies.

engeldimo

Programmer
Oct 19, 2010
2
0
0
DE
Hello people,

I'm trying to write perl-file where you can input for example your name and afterwards it is put out what you put in.
But this program doesn't work. What could be wrong?

Here is the code of this file:

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<h1>Input-Test</h1>";
print STDOUT "Enter your Name: \a\n";
$name =<STDIN>;
print <<end;
<html>
<head>
<title>Input-Test</title>
</head>
<body>
<form action="$name" method="post">
 <input type="text" size="20" name="Name">
</form>
</body>
</html>

end
if ($name){
print "You entered... ", $name, "\n\a";
}

I hope someone can help me.

greetings,
engeldimo
 
CGI processing is a two-step process. First you display a form (either using code like the beginning of your script, or just a plain HTML file), then when the user submits the form it is sent to the "second stage" which is your script to handle the submitted data. There are two methods of submission, POST where the data is sent to your script through standard input, and GET, where the data is submitted through the URL (for example the URLs on this site where you see "&variable=value" entries at the end).

In short I think you need to do a bit of reading to understand how CGI processing works before you start coding. Look into the CGI module for Perl as well, it is sure to include some example code.

Annihilannic.
 
Hello Annihilannic,

thank you very much for answer. I think I have understand it now.
So I will try it again.

[afro]engeldimo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top