input.cgi
#!/usr/bin/perl BEGIN { $| = 1; print "Content-type: text/html\n\n"; open(STDERR, ">&STDOUT"); } use CGI; my $query = CGI->new; my $name = $query->param('name'); my $add = $query->param('add'); my $tel = $query->param('tel'); my $mail = $query->param('mail'); # Get the current time my ($nsec, $nmin, $nhour, $nmday, $nmon, $nyear) = localtime(time); $nmon++; $nyear += 1900; my $day = "$nyear\t$nmon\t$nmday\t$nhour\t$nmin"; # Write to an external file my $data = "$day\t$name\t$add\t$tel\t$mail\n"; open(my $file, '>>', 'save.txt') or die "Could not open save.txt: $!"; print $file $data; close($file); # HTML Output print <<END; <html> <head> <title>Input</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <div align="center"> <h1>データベース初歩</h1> <hr> END print "入力内容は,下記のとおりです。<br><br>\n"; print "入力日時: $day<br>\n"; print "お名前: $name<br>\n"; print "ご住所: $add<br>\n"; print "電話番号: $tel<br>\n"; print "メールアドレス: $mail<br>\n"; print <<END; </div> </body> </html> END --------------------------------------------------------
<html><head>title>データベース初歩</title></head>
<body><center>
<form method=”post”action=”input.cgi”><br><br>
<h1>データベース初歩</h1><br>
お名前<br>
<input type=”text”name=”name”><br><br>
住所<br>
<input type=”text”name=”add”><br><br>
電話番号<br>
<input type=”text”name=”te1″><br><br>
メルアドレス<br>
<input type=”text”name=”mail”><br><br>
<input type=”submit”value=”送信する”><br>
<input type=”reset”value=”リセット>
</form></center>
</body></html>