mscupdate

戻る

#!C:/perl/bin/perl ###################################### # mscupdate.pl ###################################### use strict; use DBI; use CGI qw/:standard/; use HTML::Template; my ( %t, @rec, @loop ); $t{q} = new CGI; $t{enq1_id} = $t{q}->param("enq1_id"); $t{id1} = $t{q}->param("id1"); $t{table} = $t{q}->param("table"); $t{item} = $t{q}->param("item"); $t{template} = HTML::Template->new(filename => 'mscupdate.htm'); $t{dsn} = "DBI:mysql:host=localhost;database=cookbook"; $t{dbh} = DBI->connect($t{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n"; $t{dbh}->do("SET NAMES utf8"); if(!$t{dbh}){ print "SQL read ERROR!\n"; exit; } if ( $t{id1} != 0 ) { $t{name1id} = $t{dbh}->selectrow_array("select $t{item} from enq1 where id = $t{enq1_id}"); if ( $t{name1id} ) { $t{name1id_new} = $t{name1id} . '==' . $t{id1}; } else { $t{name1id_new} = $t{id1}; } $t{sql} = 'UPDATE enq1 set ' . $t{item} . ' = "'; $t{sql} .= $t{name1id_new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $t{dbh}->do($t{sql}); } $t{dbh}->disconnect; $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(id1 => $t{id1}); $t{template}->param(table => $t{table}); $t{template}->param(DO => $t{DO}); $t{template}->param(sql => $t{sql}); if ( $t{DO} ) { $t{template}->param(OK1 => 1); $t{template}->param(OK2 => 0); } else { $t{template}->param(OK1 => 0); $t{template}->param(OK2 => 1); } # send the obligatory Content-Type and print the template output print $t{template}->output; 1; ------------------------------------------------------------------------------- <html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head><title>mscupdate</title> <head> <body bgcolor="#fcf5ca"> <h2>mscupdate</h2> <a href="http://localhost/scripts/mscenq1_p.pl">http://localhost/scripts/mscenq1_p.pl</a><br> <form method="POST" action="mscsearch.pl"> <input type="submit" value="戻る"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="table" value="<TMPL_VAR NAME="table">"> table==><TMPL_VAR NAME="table"> </form> <hr> ENQ_ID==><TMPL_VAR NAME="enq1_id"><br> id1==><TMPL_VAR NAME="id1"> <hr> DO==><TMPL_VAR NAME="DO"><br> sql==><TMPL_VAR NAME="sql"><br> <TMPL_IF NAME="OK1"> 成功しました。上のmscenq1_p.plをクリックしてください。 </TMPL_IF> <TMPL_IF NAME="OK2"> 選択していません。上の「戻る」をクリックしてください。 </TMPL_IF> </body> </html>
戻る