0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Perl: POST データの処理

Posted at

Perl で Post のデータを処理するサンプルです。

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
<title>Form</title>
</head>
<body>
<FORM method="POST" action="./test_perl.pl">
<TABLE>
<TBODY>
<TR>
<TD>数量 :</TD>
<TD><INPUT type="text" name="apple" size="3" value="1"></TD>
<TD></TD>
<TD>
<button>カゴに入れます</button>
</TD>
</TR>
</TBODY>
</TABLE>
</FORM>
<hr />
Jul/10/2020<br />
</body>
</html>
test_perl.pl
# ! /usr/bin/perl
#
#	test_perl.pl
#
#					Jul/10/2020
#
use strict;
use warnings;
use CGI;
#
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
print "<title>CGI テスト</title>\n";
print "</head>\n";
print "<body>\n";
print "CGI テスト<p />\n";
#
my $q = new CGI;
for my $param_name ($q->param) {
	print $param_name . ' = ' . $q->param($param_name) . '<p />';
}

#
print "<p />\n";
print "Jul/10/2020<p />\n";
print "</body>\n";
print "</html>\n";

数量を入力
form_aa.png

ボタンをクリック
form_bb.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?