#!/usr/bin/perl #---------------- # program-ID:pet44.cgi # auther :t-egi # date :2002/2/14 #---------------- use CGI; use DBI; $query = new CGI; my $iBangou = $query->param('ibangou'); my $iAnimal = $query->param('ianimal'); my $iType = $query->param('itype'); my $iPhoto = $query->param('iphoto'); my $iHeight = $query->param('iheight'); my $iWeight = $query->param('iweight'); my $iChara = $query->param('ichara'); my $sw_UPDATE = $query->param('UPDATE'); my $sw_DELETE = $query->param('DELETE'); my $sw_INSERT = $query->param('INSERT'); print "Content-Type: text/html\n\n"; #----------- $username="egi"; $dbh = DBI->connect("dbi:Pg:dbname=egi",$username) or die "Cannot connect: ", $DBI->errstr; if($sw_UPDATE){ $iUpdate = "UPDATE pet_list Set bangou = ?, animal = ?, type = ?, photo = ?, height = ?, weight = ?, chara =?"; $iUpdate .= " Where bangou = ? "; $sth = $dbh->prepare($iUpdate) or die "Cannot prepare: ", $dbh->errstr(); $result = $sth->execute($iBangou,$iAnimal,$iType,$iPhoto,$iHeight,$iWeight,$iChara,$iBangou) or die "Cannot execute: ", $sth->errstr(); $message = "訂正しました"; } elsif($sw_DELETE){ $iDelete = "Delete from pet_list where bangou = ?"; $sth = $dbh->prepare($iDelete) or die "Cannot prepare: ", $dbh->errstr(); $result = $sth->execute($iBangou) or die "Cannot execute: ", $sth->errstr(); $message = "削除しました"; } elsif($sw_INSERT){ $iInsert = "INSERT INTO pet_list VALUES (?, ?, ?, ?, ?, ?, ?)"; $sth = $dbh->prepare($iInsert) or die "Cannot prepare: ", $dbh->errstr(); $result = $sth->execute($iBangou,$iAnimal,$iType,$iPhoto,$iHeight,$iWeight,$iChara) or die "Cannot execute: ", $sth->errstr(); $message = "追加しました"; } #---------------------- print "<html>\n"; print "<head><title>更新結果</title></head>\n"; print "<body bgcolor =LINEN>\n"; print "<center>\n"; print "<h4>\n"; print "<i>更新結果</i>\n"; print "<p>$message<br>"; print "<p><a href=./pet41.cgi>戻る</a>"; print "</center>\n"; print "</body>\n"; print "</html>\n";