回複:a perl question on file upload

#!/usr/usc/bin/perl use CGI qw(:standard); use DBI; $tempfn = param('filename'); print header; print

Purchase order summary



Product Order Summry


eof if(!$tempfn) { print "Invalid file input!"; } $dbh=DBI->connect("dbi:mysql:newsql:csci351.usc.edu:58888", "root","") || die $DBI::err; while($line = ) { ($cName,$pID,$tquantity)=split(",", $line); $sth =$dbh->prepare("select * from myTable where productID = \"$pID\";"); $sth->execute; @rowID = $sth->fetchrow_array(); $temp1 =$dbh->prepare("select * from companyTable where companyName = \"$cName\";"); $temp1->execute; @rowName = $temp1->fetchrow_array(); if(!$rowName[0]) { print "Please register company ".$cName." first!!"; } elsif(!$rowID[0]) { print $pID."----Invalid Product ID!!"; } else { @date = localtime(); $year = $date[5]+1900; $month = $date[4]+1; $day = $date[3]; $temp = $year.'-'.$month.'-'.$day; $temp2=$dbh->prepare("insert into orderTable (companyName, productID,quantity,orderDate,sentInvoice) values (\"$cName\", $pID, $tquantity,\"$temp\",\"FALSE\")"); $temp2->execute; print "You Ordered ".$tquantity." of product----".$pID; $temp3=$dbh->prepare("select * from orderTable where companyName = \"$cName\" and productID = $pID and quantity = $tquantity and orderDate = \"$temp\";"); $temp3->execute(); @aaaa=$temp3->fetchrow_array(); print "
"."This purchase order's Order number is: ".$aaaa[3]; print "
"."Thank you! Your order is being processed!"."
"; } } $sth->finish; $temp1->finish; $temp2->finish; $dbh->disconnect; print


HomePage eof

請您先登陸,再發跟帖!