File "info.php"

Full path: /www/nakagusuku/wpos/edit/info.php
File size: 3.53 KiB (3617 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
$editid = isset($_GET["dispno"]) ? htmlspecialchars($_GET["dispno"]) : "";

print "<html>";
print "<head>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"/ansys/config/css/style.css\">";
print "<link rel=\"shortcut icon\" href=\"/ansys/config/favicon.ico\">";
print "<title>退避監視システム</title>";
print "</head>";

print "<body>";
print "<center>";
print "<font size=\"3\"><b>";
print "退避監視システム<br>-状態編集-";
print "【五洋建設株式会社】";
print "</b></font>";
print "</center>";
print "<hr />";

try
{
	if (strcmp($editid, "") == 0)
	{
		$editid = isset($_POST["hipid"]) ? htmlspecialchars($_POST["hipid"]) : "";
		if (strcmp($editid, "") == 0)
			throw new Exception("IDが指定されていません");
	}
	
	$conn = pg_connect("
	host	=	192.168.100.153
	dbname	=	cnbs
	user	=	postgres
	password=	am#71ZJ*
	");
	if (!$conn)
		throw new Exception("データベースへの接続に失敗");
	
	$btnref = isset($_POST["btnref"]) ? htmlspecialchars($_POST["btnref"]) : "";
	if (strcmp($btnref, "更新") == 0)
	{
		$chdispno = isset($_POST["txteditdispno"]) ? htmlspecialchars($_POST["txteditdispno"]) : "";
		if (strcmp($chdispno, "") == 0)
			throw new Exception("表示番号の指定が正しくありません");
		$chwname = isset($_POST["txteditwname"]) ? htmlspecialchars($_POST["txteditwname"]) : "";
		if (strcmp($chwname, "") == 0)
			throw new Exception("氏名の指定が正しくありません");
		$chtagid = isset($_POST["txtedittagid"]) ? htmlspecialchars($_POST["txtedittagid"]) : "";
		if (strcmp($chtagid, "") == 0)
			throw new Exception("氏名の指定が正しくありません");
		$updateDno = "UPDATE nakagusuku.worker_info SET dispno='". $chdispno. "', wname='". $chwname. "', tagid='". $chtagid. "' WHERE pid='". $editid. "';";
		//print $updateDno. "<br>";
		pg_query($conn, $updateDno);
		print "<font color=\"#ff0000\">";
		print "状態を更新しました<br>";
		print "</font>";
	}
	
	$selectWrk = "SELECT dispno, wname, tagid FROM nakagusuku.worker_info WHERE pid=". $editid. ";";
	$res = pg_query($conn, $selectWrk);
	
	$rowcnt = pg_num_rows($res);
	if ($rowcnt == 0)
		throw new Exception("指定されたIDのデータは存在しません");
	
	$row = pg_fetch_assoc($res, 0);
	
	print "<form method=\"post\">";
	print "<center>";
	print "<table border=\"1\" style=\"width:50%\">";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">表示番号</th><td><input type=\"text\" name=\"txteditdispno\" value=\"". $row["dispno"]. "\" style=\"width:100%;\"></td></tr>";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">タグID</th><td><input type=\"text\" name=\"txtedittagid\" value=\"". $row["tagid"]. "\" style=\"width:100%;\"></td></tr>";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">氏名</th><td><input type=\"text\" name=\"txteditwname\" value=\"". $row["wname"]. "\" style=\"width:100%;\"></td></tr>";
	print "<tr align=\"right\"><th colspan=\"2\"><input type=\"submit\" name=\"btnref\" value=\"更新\"></th></tr>";
	print "</table>";
	print "</center>";
	print "<input type=\"hidden\" name=\"hipid\" value=\"". $editid. "\">";
	print "</form>";
}
catch(Exception $exc)
{
	print "<font color=\"#ff0000\">";
	print $exc. "<br>";
	print "</font>";
}
pg_close($conn);

print "<p style=\"text-align:right;\">";
print "<a href=\"./listi.php\">戻る</a>";
print "</p>";
print "<hr>";
print "<center>";
print "<font size=\"3\" face=\"Arial\"><b><i>";
print "penta-ocean";
print "</i></b></font>";
print "</center>";
?>

PHP File Manager