0

All, I have a simple question.

What is the standard procedure for retrieving form values via POST method in a web form? Perl can be extremely awkward for web programming, I'd normally use something else, but in this case I need to use Perl for the CPAN module.

Anyway, back to the point, If I have a basic html form, how do I get the values out in verify_login?

<form name="login" action="$cgidir?action=verify_login" method="POST">
    <input type="text" name="user">
    <input type="password" name="pass">
    <input type="submit" name="login" value="Login">
</form>
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by nonshatter
1

<form name="login" action="$cgidir?action=verify_login" method="POST"> The above doesn't look right to me. To get it to work I put it in an html document like the following:

<html>
<header>
<title>Post form example</title>
</header>
<body>
<form name="login" action="/cgi-bin/verify_login" method="POST">
    <input type="text" name="user">
    <input type="password" name="pass">
    <input type="submit" name="login" value="Login">
</form>
</body>
</html>

Then your verify_login can read what the form POSTed by using the CGI module and its param method.

#!/usr/bin/perl
#/cgi-bin/verify_login
use strict;
use warnings;

use CGI qw(:standard);
my $cgi=new CGI; #read in parameters

print $cgi->header(); #print a header
print $cgi->start_html("Welcome"); #generate HTML document start
print "<h1>Welcome, ",$cgi->param('user'),". Your password is ",$cgi->param('pass'),"</h1></p>";
print "But I won't tell anyone.</p>";
print $cgi->end_html();#finish HTML document
Votes + Comments
Consistently clear and useful posts.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.