Reputation: 39
I'm, trying to run a perl script from html, but I'm getting error during execution. Here is my html and 2 lines perl code. The error code is not very descriptive just says "Internal Server Error" and some other lines. I also want to know how to display the receive user name in the perl script.
pwd
/var/www/cgi-bin
ls -l
total 4
-rwxr-xr-x 1 root root 49 Aug 26 16:49 username.pl
Html Code:
<html>
<head>
</head>
<body>
<h1> Hello </h1>
<form action="/cgi-bin/username.pl" method="POST">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
Perl code:
#!/usr/bin/perl
print "Received user name is\n";
Upvotes: 0
Views: 1180
Reputation: 2783
1>.my declares the listed variables to be local to the enclosing block, file.
2>.if you have a text box name user in your html page
i.e. something like this:-
<td><b><font color="green" size="3">USER</font><input type="text" name="user" value="">
then try this
my $user=$query->param("user");
in your cgi script and get the input in the variable $user.
Upvotes: 1
Reputation:
Your Perl script is not generating appropriate CGI headers. Please read perldoc CGI
, or, for a quick answer:
#!/usr/bin/perl
use strict;
use CGI;
my $q = CGI->new();
my $username = $q->param("username");
print $q->header(-type => "text/plain");
print "Received username is $username\n";
Upvotes: 2