<?php 
error_reporting(E_ALL);          //顯示php error
ini_set("display_errors", 1);	//顯示php ERROR
ini_set('display_startup_errors', TRUE);

if (!isset($_GET['lang']) && !isset($_POST['lang'])){
	$lang = "chi";
} else {
	if ((isset($_GET['lang']) && $_GET['lang']  == "chi" )|| (isset($_POST['lang']) && $_POST['lang'] =="chi")) {
		$lang="chi";

    } else {
		$lang = "en";
	}
}
require "spconfig.php";

  if ($lang == "chi"){
        require "language/chi.php";
	  $txtsuccessaddnewstaff ="成功增加職員";
    ?>
      <a href="?lang=en">English</a><br>
      <?php
  } else {
        require "language/eng.php";
     $txtsuccessaddnewstaff ="Success add New staff";
  ?>
      <a href="?lang=chi">中文</a><br>
      <?php 
 }
$finishinitalDB="";




if (isset($_POST['initaldatabase'])) {
 

$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `APPLICATION_COMPETITION`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `APPLICATION_COMPETITION` (`keyid` int(11) NOT NULL, `SCHYEAR` int(4) NOT NULL,`STUID` text NOT NULL,  `CHOICE` varchar(1) NOT NULL, `COMPETITION_ID` int(5) NOT NULL, `ATTENDANCE` int(2) DEFAULT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `APPLICATION_STUDENTWORKER`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `APPLICATION_STUDENTWORKER` (`keyid` int(11) NOT NULL, `SCHYEAR` int(4) NOT NULL,  `STUID` varchar(10) NOT NULL,  `choice` int(1) NOT NULL,  `sw_id` int(11) NOT NULL,  `approved` int(1) NOT NULL,  `approvedby` varchar(10) NOT NULL,  `exported` int(1) NOT NULL,  `PREF_ID` varchar(2) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `BEST_RECORD`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `BEST_RECORD` (`keyid` int(11) NOT NULL,  `SCHYEAR` int(4) NOT NULL,  `COMPETITION_ID` int(11) NOT NULL,  `NAME` varchar(50) NOT NULL,  `HOUSE` varchar(1) NOT NULL,  `RECORD` varchar(11) NOT NULL,  `STANDARD` varchar(11) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `COMPETITION_DATEID`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `COMPETITION_DATEID` (`keyid` int(11) NOT NULL,  `COMPETITION_ID` int(4) NOT NULL,  `DATE` varchar(10) NOT NULL,  `ORDER_ID` int(2) NOT NULL,  `HeatorFinal` int(11) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `CONFIRMED_RESULT`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `CONFIRMED_RESULT` (`keyid` int(11) NOT NULL,  `SCHYEAR` int(4) NOT NULL,  `COMPETITION_ID` varchar(10) NOT NULL,  `EVENT_ID` varchar(3) NOT NULL,  `STUID` varchar(10) NOT NULL,  `HeatorFinal` int(1) NOT NULL DEFAULT '0',  `RANK` varchar(3) NOT NULL,  `RESULT` varchar(11) NOT NULL,  `is_NEWRECORD` int(1) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `gradeyear`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `gradeyear` (`keyid` int(11) NOT NULL,  `SCHYEAR` int(4) NOT NULL,  `grade` varchar(1) NOT NULL,  `gradeyear` int(4) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `HEAT_RESULT`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `HEAT_RESULT` (`keyid` int(11) NOT NULL,  `COMPETITION_ID` int(10) NOT NULL,  `STUID` varchar(10) NOT NULL,  `RESULT` varchar(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `HOUSE_MEMBER`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `HOUSE_MEMBER` (  `STUID` varchar(10) DEFAULT NULL,  `HOUSE` varchar(1) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `HOUSE_SCORE`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `HOUSE_SCORE` (`keyid` int(11) NOT NULL,  `SCHYEAR` varchar(4) NOT NULL,  `SCHHOUSE` varchar(10) NOT NULL,  `GRADE` varchar(1) NOT NULL,  `SEX` varchar(1) NOT NULL,  `SCORE` int(5) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `INTERHOUSE_COMPETITION`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `INTERHOUSE_COMPETITION` (`keyid` int(11) NOT NULL,  `COMPETITION_ID` int(10) NOT NULL,  `SCHHOUSE` varchar(1) NOT NULL,  `TEAM` varchar(1) NOT NULL,  `STUID` varchar(10) NOT NULL,  `LANE_NO` int(1) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `INTERHOUSE_RESULT`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `INTERHOUSE_RESULT` (`keyid` int(11) NOT NULL,  `SCHYEAR` varchar(4) NOT NULL,  `COMPETITION_ID` int(10) NOT NULL,  `SCHHOUSE` varchar(1) NOT NULL,  `TEAM` varchar(1) NOT NULL,  `RESULT` varchar(11) NOT NULL,  `ATTENDANCE` int(1) NOT NULL DEFAULT '0',  `RANK` varchar(2) NOT NULL,  `is_NEWRECORD` int(11) NOT NULL DEFAULT '0') ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `moduleenable`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `moduleenable` (`keyid` int(11) NOT NULL,  `module` varchar(100) NOT NULL,  `apenable` int(11) NOT NULL,  `Start_date` date NOT NULL,  `End_date` date NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `moduleuser`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `moduleuser` (`keyid` int(11) NOT NULL,  `modulephp` varchar(50) NOT NULL,  `displayorder` int(11) NOT NULL DEFAULT '0',  `modulename` varchar(20) NOT NULL,  `users` text) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `NEW_RECORD`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `NEW_RECORD` (`keyid` int(11) NOT NULL,  `SCHYEAR` int(4) NOT NULL,  `COMPETITION_ID` int(11) NOT NULL,  `STUID` int(11) NOT NULL,  `RECORD` varchar(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `SCHYEAR`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `SCHYEAR` (`keyid` int(11) NOT NULL,  `SCHYEAR` varchar(4) NOT NULL,  `activeyear` int(11) NOT NULL DEFAULT '0',  `EVENT_CHNAME` varchar(100) NOT NULL,  `EVENT_ENNAME` varchar(100) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
if (date("M") > 8) {
  $year = date("Y");
} else {
  $year = date("Y") - 1;
}
$sql= mysqli_query($splink,"Insert into SCHYEAR (SCHYEAR,activeyear,EVENT_CHNAME,EVENT_ENNAME) VALUES (\"".$year."\",\"1\",\"測試\",\"TEST\")");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `staffduty`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `staffduty` (`keyid` int(11) NOT NULL,  `CH_DES` varchar(100) NOT NULL,  `EN_DES` varchar(100) NOT NULL,  `STAFF` varchar(500) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `studentinfo`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `studentinfo` (  `CHNAME` varchar(18) DEFAULT NULL,  `ENNAME` varchar(26) DEFAULT NULL,  `SEX` varchar(1) DEFAULT NULL,  `CLASSCODE` varchar(2) DEFAULT NULL,  `CLASSNO` int(2) DEFAULT NULL,  `DOB` date DEFAULT NULL,  `REGNO` varchar(6) DEFAULT NULL,  `SCHHOUSE` varchar(1) DEFAULT NULL,  `SCHLEAVERSIGN` int(1) DEFAULT NULL,  `STUID` varchar(10) DEFAULT NULL,  `SUID` int(3) DEFAULT NULL,  `password` varchar(200) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `studentworker`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `studentworker` (`keyid` int(11) NOT NULL,  `CH_DES` varchar(100) NOT NULL,  `EN_DES` varchar(200) NOT NULL,  `NEED_NUM` int(2) NOT NULL,  `REQUIRE_SEX` int(1) NOT NULL,  `CH_REMARK` varchar(1000) NOT NULL,  `EN_REMARK` varchar(1000) NOT NULL,  `allowapply` int(1) NOT NULL DEFAULT '0',  `activated` int(1) NOT NULL DEFAULT '1') ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `STU_SCORE`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `STU_SCORE` (`keyid` int(11) NOT NULL,  `SCHYEAR` varchar(4) NOT NULL,  `STUID` varchar(10) NOT NULL,  `SCORE` int(5) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `SW_PFM`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `SW_PFM` (  `CH_ABBR` varchar(100) DEFAULT NULL,  `CH_DES` varchar(200) DEFAULT NULL,  `CH_SNAME` varchar(100) DEFAULT NULL,  `CODE_ID` varchar(10) DEFAULT NULL,  `CODE_ST` varchar(1) DEFAULT NULL,  `CODE_TYPE` varchar(1) DEFAULT NULL,  `EN_ABBR` varchar(100) DEFAULT NULL,  `EN_DES` varchar(200) DEFAULT NULL,  `EN_SNAME` varchar(20) DEFAULT NULL,  `EXP_DATE` datetime DEFAULT NULL,  `EXP_FLAG` int(1) DEFAULT NULL,  `FLAG_1` int(1) DEFAULT NULL,  `FLAG_2` int(1) DEFAULT NULL,  `FLAG_3` int(1) DEFAULT NULL,  `NUM_1` varchar(20) DEFAULT NULL,  `STR_1` varchar(1) DEFAULT NULL,  `SUID` int(3) DEFAULT NULL,  `TB_ID` varchar(20) DEFAULT NULL,  `updversion` int(20) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `TB_STU_STUDENT`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `TB_STU_STUDENT` (  `REGNO` varchar(10) NOT NULL,  `STUID` varchar(10) NOT NULL DEFAULT '',  `password` varchar(200) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `teacherinfo`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `teacherinfo` (  `STAFFCODE` varchar(10) NOT NULL,  `STAFFUID` varchar(10) NOT NULL,  `CH_NAME` varchar(255) NOT NULL,  `EN_NAME` varchar(255) DEFAULT NULL,  `stafftitle` varchar(10) NOT NULL,  `password` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `TRACKEVENT_FINAL_LANE`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `TRACKEVENT_FINAL_LANE` (`keyid` int(11) NOT NULL,  `COMPETITION_ID` int(10) NOT NULL,  `STUID` varchar(10) NOT NULL,  `LANE_NO` int(1) NOT NULL,  `ATTENDANCE` int(11) NOT NULL,  `RESULT` varchar(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `TRACKEVENT_HEAT_LANE`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `TRACKEVENT_HEAT_LANE` (`keyid` int(11) NOT NULL,  `EVENT_ID` int(11) NOT NULL,  `COMPETITION_ID` int(10) NOT NULL,  `STUID` varchar(10) NOT NULL,  `LANE_NO` int(1) NOT NULL,  `ATTENDANCE` int(1) NOT NULL DEFAULT '0',  `RESULT` varchar(11) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"DROP TABLE IF EXISTS `UNIT`");
$sql=mysqli_query($splink,"CREATE TABLE IF NOT EXISTS `UNIT` (`keyid` int(11) NOT NULL,  `CH_DES` varchar(20) NOT NULL,  `EN_DES` varchar(20) NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$sql=mysqli_query($splink,"ALTER TABLE `APPLICATION_COMPETITION` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `APPLICATION_STUDENTWORKER` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `BEST_RECORD` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `COMPETITIONITEM` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `COMPETITION_DATEID` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `CONFIRMED_RESULT` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `gradeyear` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `HEAT_RESULT` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `HOUSE_SCORE` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `INTERHOUSE_COMPETITION` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `INTERHOUSE_RESULT` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `moduleenable` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `moduleuser` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `NEW_RECORD` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `SCHYEAR` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `staffduty` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `studentworker` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `STU_SCORE` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `SW_PFM` ADD KEY `CODE_ID` (`CODE_ID`)");
$sql=mysqli_query($splink,"ALTER TABLE `TB_STU_STUDENT` ADD PRIMARY KEY (`STUID`), ADD UNIQUE KEY `STUID` (`STUID`)");
$sql=mysqli_query($splink,"ALTER TABLE `TRACKEVENT_FINAL_LANE` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `TRACKEVENT_HEAT_LANE` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `UNIT` ADD PRIMARY KEY (`keyid`)");
$sql=mysqli_query($splink,"ALTER TABLE `APPLICATION_COMPETITION` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `APPLICATION_STUDENTWORKER` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `BEST_RECORD` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `COMPETITIONITEM` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `COMPETITION_DATEID` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `CONFIRMED_RESULT` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `gradeyear` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `HEAT_RESULT` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `HOUSE_SCORE` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `INTERHOUSE_COMPETITION` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `INTERHOUSE_RESULT` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `moduleenable` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `moduleuser` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `NEW_RECORD` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `SCHYEAR` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `staffduty` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `studentworker` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `STU_SCORE` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `TRACKEVENT_FINAL_LANE` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT");
$sql=mysqli_query($splink,"ALTER TABLE `TRACKEVENT_HEAT_LANE` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"ALTER TABLE `UNIT` MODIFY `keyid` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
$sql=mysqli_query($splink,"INSERT INTO `studentworker` (`keyid`, `CH_DES`, `EN_DES`, `NEED_NUM`, `REQUIRE_SEX`, `CH_REMARK`, `EN_REMARK`, `allowapply`, `activated`) VALUES (1, '彎道/數圈員', '', 9, 0, '多於100M的賽事工作', '', 1, 0),(2, '線道', '', 6, 0, '確保運動員上線正確', '', 1, 1),(3, '終點傳遞員', '', 4, 0, '', '', 1, 1),(4, '召集', '', 6, 0, '', '', 1, 1),(5, '發令', '', 6, 0, '', '', 1, 1),(6, '計時', '', 14, 0, '', '', 1, 1),(7, '終點裁判員', '', 14, 0, '', '', 1, 1),(8, '終點紀錄員', '', 6, 0, '', '', 1, 1),(9, '鉛球', '', 6, 0, '', '', 1, 1),(10, '跳高', '', 6, 0, '', '', 1, 1)");
$sql=mysqli_query($splink,"INSERT INTO `studentworker` (`keyid`, `CH_DES`, `EN_DES`, `NEED_NUM`, `REQUIRE_SEX`, `CH_REMARK`, `EN_REMARK`, `allowapply`, `activated`) VALUES (11, '鐵餅', '', 6, 0, '', '', 1, 1),(12, '跳遠', '', 12, 1, '', '', 1, 1),(13, '標槍', '', 6, 0, '', '', 1, 1),(14, '用具', '', 6, 0, '', '', 1, 1),(15, '宣佈', '', 3, 0, '由數名老師甄選', '', 1, 1),(16, '司令台紀錄員', '', 8, 0, '', '', 1, 1),(17, '電腦輸入', '', 2, 0, '', '', 1, 1),(18, '彎道/數圈員', '', 10, 0, '多於100M的賽事工作', '', 1, 1)");
$sql=mysqli_query($splink,"INSERT INTO `SW_PFM` (`CH_ABBR`, `CH_DES`, `CH_SNAME`, `CODE_ID`, `CODE_ST`, `CODE_TYPE`, `EN_ABBR`, `EN_DES`, `EN_SNAME`, `EXP_DATE`, `EXP_FLAG`, `FLAG_1`, `FLAG_2`, `FLAG_3`, `NUM_1`, `STR_1`, `SUID`, `TB_ID`, `updversion`) VALUES ('', 'A', '', '01', 'A', 'S', '', 'A', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994964),('', 'A-', '', '02', 'A', 'S', '', 'A-', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994964),('', 'B+', '', '03', 'A', 'S', '', 'B+', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994964),('', 'B', '', '04', 'A', 'S', '', 'B', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994964),('', 'B-', '', '05', 'A', 'S', '', 'B-', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994974),('', 'C+', '', '06', 'A', 'S', '', 'C+', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994974),('', 'C', '', '07', 'A', 'S', '', 'C', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994974),('', 'C-', '', '08', 'A', 'S', '', 'C-', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994974),('', 'D', '', '09', 'A', 'S', '', 'D', '', '0000-00-00 00:00:00', 0, 0, 0, 0, '0.000000', '', 000, 'ECAPFM', 878994974)");
$sql=mysqli_query($splink,"INSERT INTO `UNIT` (`keyid`, `CH_DES`, `EN_DES`) VALUES (1, '距離', 'Distance'),(2, '時間', 'Times')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (1, 1, '男子甲組一百米', 'Boys-A 100m', 'A', 1, 1, 1, 0, 0, 0, 0, '00:00:13.50', ''),(2, 1, '女子甲組一百米', 'Girls-A 100m', 'A', 1, 2, 1, 0, 0, 0, 0, '00:00:17.00', ''),(3, 1, '男子乙組一百米', '', 'B', 1, 1, 1, 0, 0, 0, 0, '', ''),(4, 1, '女子乙組一百米', '', 'B', 1, 2, 1, 0, 0, 0, 0, '', ''),(5, 1, '男子丙組一百米', '', 'C', 1, 1, 1, 0, 0, 0, 0, '', ''),(6, 1, '女子丙組一百米', '', 'C', 1, 2, 1, 0, 0, 0, 0, '', ''),(7, 1, '女子甲組一百米欄(76.2cm)', '', 'A', 1, 2, 1, 0, 0, 0, 0, '', ''),(8, 1, '男子乙組一百米欄(91.4cm)', '', 'B', 1, 1, 1, 0, 0, 0, 0, '', ''),(9, 1, '女子乙組一百米欄(76.2cm)', '', 'B', 1, 2, 1, 0, 0, 0, 0, '', ''),(10, 1, '男子丙組一百米欄(84cm)', '', 'C', 1, 1, 1, 0, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (11, 1, '女子丙組一百米欄(76.2cm)', '', 'C', 1, 2, 1, 0, 0, 0, 0, '', ''),(12, 1, '男子甲組一百一十米欄(91.4cm)', '', 'A', 1, 1, 1, 0, 0, 0, 0, '', ''),(13, 1, '男子甲組一千五百米', '', 'A', 1, 1, 0, 0, 0, 0, 0, '', ''),(14, 1, '女子甲組一千五百米', '', 'A', 1, 2, 0, 0, 0, 0, 0, '', ''),(15, 1, '男子乙組一千五百米', '', 'B', 1, 1, 0, 0, 0, 0, 0, '', ''),(16, 1, '女子乙組一千五百米', '', 'B', 1, 2, 0, 0, 0, 0, 0, '', ''),(17, 1, '男子丙組一千五百米', '', 'C', 1, 1, 0, 0, 0, 0, 0, '', ''),(18, 1, ' 女子丙組一千五百米', '', 'C', 1, 2, 0, 0, 0, 0, 0, '', ''),(19, 1, '男子甲組二百米', '', 'A', 1, 1, 1, 0, 0, 0, 0, '', ''),(20, 1, '女子甲組二百米', '', 'A', 1, 2, 1, 0, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (21, 1, '男子乙組二百米', '', 'B', 1, 1, 1, 0, 0, 0, 0, '', ''),(22, 1, '女子乙組二百米', '', 'B', 1, 2, 1, 0, 0, 0, 0, '', ''),(23, 1, '男子丙組二百米', '', 'C', 1, 1, 1, 0, 0, 0, 0, '', ''),(24, 1, '女子丙組二百米', '', 'C', 1, 2, 1, 0, 0, 0, 0, '', ''),(25, 1, '男子甲組三千米', '', 'A', 1, 1, 0, 0, 0, 0, 0, '', ''),(26, 1, '男子乙組三千米', '', 'B', 1, 1, 0, 0, 0, 0, 0, '', ''),(27, 1, '男子丙組三千米', '', 'C', 1, 1, 0, 0, 0, 0, 0, '', ''),(28, 1, '男子甲組四百米', '', 'A', 1, 1, 1, 0, 0, 0, 0, '', ''),(29, 1, '女子甲組四百米', '', 'A', 1, 2, 1, 0, 0, 0, 0, '', ''),(30, 1, '男子乙組四百米', '', 'B', 1, 1, 1, 0, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (31, 1, '女子乙組四百米', '', 'B', 1, 2, 1, 0, 0, 0, 0, '', ''),(32, 1, '男子丙組四百米', '', 'C', 1, 1, 1, 0, 0, 0, 0, '', ''),(33, 1, '女子丙組四百米', '', 'C', 1, 2, 1, 0, 0, 0, 0, '', ''),(34, 1, '男子甲組八百米', '', 'A', 1, 1, 0, 0, 0, 0, 0, '', ''),(35, 1, '女子甲組八百米', '', 'A', 1, 2, 0, 0, 0, 0, 0, '', ''),(36, 1, '男子乙組八百米', '', 'B', 1, 1, 0, 0, 0, 0, 0, '', ''),(37, 1, '女子乙組八百米', '', 'B', 1, 2, 0, 0, 0, 0, 0, '', ''),(38, 1, '男子丙組八百米', '', 'C', 1, 1, 0, 0, 0, 0, 0, '', ''),(39, 1, '女子丙組八百米', '', 'C', 1, 2, 0, 0, 0, 0, 0, '', ''),(40, 1, '班際4x100接力', '', 'O', 1, 0, 0, 0, 0, 1, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (41, 1, '男子甲組擲鐵餅(1.5kg)', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(42, 1, '女子甲組擲鐵餅(1kg)', '', 'A', 2, 2, 0, 1, 0, 0, 0, '', ''),(43, 1, '男子乙組擲鐵餅(1kg)', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', ''),(44, 1, '女子乙組擲鐵餅(1kg)', '', 'B', 2, 2, 0, 1, 0, 0, 0, '', ''),(45, 1, '男子甲組跳高', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(46, 1, '女子甲組跳高', '', 'A', 2, 2, 0, 1, 0, 0, 0, '', ''),(47, 1, '男子乙組跳高', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', ''),(48, 1, '女子乙組跳高', '', 'B', 2, 2, 0, 1, 0, 0, 0, '', ''),(49, 1, '男子丙組跳高', '', 'C', 2, 1, 0, 1, 0, 0, 0, '', ''),(50, 1, '女子丙組跳高', '', 'C', 2, 2, 0, 1, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (51, 1, '男子甲組社際接力4x100', '', 'A', 1, 1, 0, 0, 1, 0, 0, '', ''),(52, 1, '女子甲組社際接力4x100', '', 'A', 1, 2, 0, 0, 1, 0, 0, '', ''),(53, 1, '男子乙組社際接力4x100', '', 'B', 1, 1, 0, 0, 1, 0, 0, '', ''),(54, 1, '女子乙組社際接力4x100', '', 'B', 1, 2, 0, 0, 1, 0, 0, '', ''),(55, 1, '男子丙組社際接力4x100', '', 'C', 1, 1, 0, 0, 1, 0, 0, '', ''),(56, 1, '女子丙組社際接力4x100', '', 'C', 1, 2, 0, 0, 1, 0, 0, '', ''),(57, 1, '男子甲組社際接力4x400', '', 'A', 1, 1, 0, 0, 1, 0, 0, '', ''),(58, 1, '女子甲組社際接力4x400', '', 'A', 1, 2, 0, 0, 1, 0, 0, '', ''),(59, 1, '男子乙組社際接力4x400', '', 'B', 1, 1, 0, 0, 1, 0, 0, '', ''),(60, 1, '女子乙組社際接力4x400', '', 'B', 1, 2, 0, 0, 1, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (61, 1, '男子丙組社際接力4x400', '', 'C', 1, 1, 0, 0, 1, 0, 0, '', ''),(62, 1, '女子丙組社際接力4x400', '', 'C', 1, 2, 0, 0, 1, 0, 0, '', ''),(63, 1, '男子甲組標槍(700g)', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(64, 1, '女子甲組標槍(600g)', '', 'A', 2, 2, 0, 1, 0, 0, 0, '', ''),(65, 1, '男子乙組標槍(600g)', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', ''),(66, 1, '女子乙組標槍(600g)', '', 'B', 2, 2, 0, 1, 0, 0, 0, '', ''),(67, 1, '男子甲組跳遠', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(68, 1, '女子甲組跳遠', '', 'A', 2, 2, 0, 1, 0, 0, 0, '', ''),(69, 1, '男子乙組跳遠', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', ''),(70, 1, '女子乙組跳遠', '', 'B', 2, 2, 0, 1, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `COMPETITIONITEM` (`keyid`, `Allowapply`, `CH_DES`, `EN_DES`, `GRADE`, `TRACKFIELD`, `SEX`, `SETLANE`, `UNIT`, `INTERHOUSE`, `INTERCLASS`, `OPENSCH`, `STANDARD`, `MEASURE`) VALUES (71, 1, '男子丙組跳遠', '', 'C', 2, 1, 0, 1, 0, 0, 0, '', ''),(72, 1, '女子丙組跳遠', '', 'C', 2, 2, 0, 1, 0, 0, 0, '', ''),(73, 1, '男子甲組推鉛球(5kg)', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(74, 1, '女子甲組推鉛球(4kg)', '', 'A', 2, 2, 0, 1, 0, 0, 0, '', ''),(75, 1, '男子乙組推鉛球(4kg)', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', ''),(76, 1, '女子乙組推鉛球(3kg)', '', 'B', 2, 2, 0, 1, 0, 0, 0, '', ''),(77, 1, '男子丙組推鉛球(4kg)', '', 'C', 2, 1, 0, 1, 0, 0, 0, '', ''),(78, 1, '女子丙組推鉛球(3kg)', '', 'C', 2, 2, 0, 1, 0, 0, 0, '', ''),(79, 1, '男子甲組三級跳', '', 'A', 2, 1, 0, 1, 0, 0, 0, '', ''),(80, 1, '男子乙組三級跳', '', 'B', 2, 1, 0, 1, 0, 0, 0, '', '')");
$sql=mysqli_query($splink,"INSERT INTO `BEST_RECORD` (`keyid`, `SCHYEAR`, `COMPETITION_ID`, `NAME`, `HOUSE`, `RECORD`, `STANDARD`) VALUES (1, 2012, 1, '陳大文', 'G', '00:00:11.20', '00:00:13.50'), (2, 1997, 2, '你好嗎', 'G', '00:00:13.10', '00:00:17.00'), (3, 2012, 51, '紅社', 'G', '00:00:48.16', '00:00:00.00')");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (1, 6, '2017-04-27', 1, 0, 0),(2, 4, '2017-04-27', 2, 0, 0),(3, 2, '2017-04-27', 3, 0, 0),(4, 73, '2017-04-27', 4, 1, 0),(5, 47, '2017-04-27', 5, 1, 0),(6, 64, '2017-04-27', 6, 1, 0),(7, 5, '2017-04-27', 7, 0, 0),(8, 3, '2017-04-27', 8, 0, 0),(9, 1, '2017-04-27', 9, 0, 0),(10, 75, '2017-04-27', 10, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (11, 70, '2017-04-27', 11, 1, 0),(12, 72, '2017-04-27', 12, 1, 0),(13, 18, '2017-04-27', 13, 1, 0),(14, 16, '2017-04-27', 14, 1, 0),(15, 14, '2017-04-27', 15, 1, 0),(16, 17, '2017-04-27', 16, 1, 0),(17, 15, '2017-04-27', 17, 1, 0),(18, 13, '2017-04-27', 18, 1, 0),(19, 46, '2017-04-27', 19, 1, 0),(20, 74, '2017-04-27', 20, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (21, 44, '2017-04-27', 21, 1, 0),(22, 33, '2017-04-27', 22, 0, 0),(23, 31, '2017-04-27', 23, 0, 0),(24, 29, '2017-04-27', 24, 0, 0),(25, 32, '2017-04-27', 25, 0, 0),(26, 63, '2017-04-27', 26, 1, 0),(27, 48, '2017-04-27', 27, 1, 0),(28, 12, '2017-04-27', 28, 1, 0),(29, 8, '2017-04-27', 29, 1, 0),(30, 7, '2017-04-27', 30, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (31, 9, '2017-04-27', 31, 0, 0),(32, 11, '2017-04-27', 32, 0, 0),(33, 10, '2017-04-27', 33, 1, 0),(34, 79, '2017-04-27', 34, 1, 0),(35, 80, '2017-04-27', 35, 1, 0),(36, 71, '2017-04-27', 36, 1, 0),(37, 42, '2017-04-27', 37, 1, 0),(38, 76, '2017-04-27', 38, 1, 0),(39, 50, '2017-04-27', 39, 1, 0),(40, 24, '2017-04-27', 40, 0, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (41, 22, '2017-04-27', 41, 0, 0),(42, 23, '2017-04-27', 42, 0, 0),(43, 21, '2017-04-27', 43, 0, 0),(45, 45, '2017-04-27', 44, 1, 0),(46, 65, '2017-04-27', 45, 1, 0),(47, 77, '2017-04-27', 46, 1, 0),(48, 68, '2017-04-27', 47, 1, 0),(49, 9, '2017-04-27', 48, 1, 0),(50, 11, '2017-04-27', 49, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (51, 62, '2017-04-27', 50, 1, 0),(52, 60, '2017-04-27', 51, 1, 0),(53, 58, '2017-04-27', 52, 1, 0),(54, 61, '2017-04-27', 53, 1, 0),(55, 59, '2017-04-27', 54, 1, 0),(56, 57, '2017-04-27', 55, 1, 0),(57, 24, '2017-05-05', 56, 1, 0),(58, 22, '2017-05-05', 57, 1, 0),(59, 20, '2017-05-05', 58, 1, 0),(60, 23, '2017-05-05', 59, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (61, 21, '2017-05-05', 60, 1, 0),(62, 19, '2017-05-05', 61, 1, 0),(63, 67, '2017-05-05', 62, 1, 0),(64, 69, '2017-05-05', 63, 1, 0),(65, 49, '2017-05-05', 64, 1, 0),(66, 66, '2017-05-05', 65, 1, 0),(67, 78, '2017-05-05', 66, 1, 0),(68, 39, '2017-05-05', 67, 1, 0),(69, 37, '2017-05-05', 68, 1, 0),(70, 35, '2017-05-05', 69, 1, 0),(71, 38, '2017-05-05', 70, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (72, 36, '2017-05-05', 71, 1, 0),(73, 34, '2017-05-05', 72, 1, 0),(74, 6, '2017-05-05', 73, 1, 0),(75, 4, '2017-05-05', 74, 1, 0),(76, 2, '2017-05-05', 75, 1, 0),(77, 5, '2017-05-05', 76, 1, 0),(78, 3, '2017-05-05', 77, 1, 0),(79, 1, '2017-05-05', 78, 1, 0),(80, 33, '2017-05-05', 79, 1, 0),(81, 31, '2017-05-05', 80, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (82, 29, '2017-05-05', 81, 1, 0),(83, 32, '2017-05-05', 82, 1, 0),(84, 30, '2017-05-05', 83, 1, 0),(85, 28, '2017-05-05', 84, 1, 0),(86, 41, '2017-05-05', 85, 1, 0),(87, 27, '2017-05-05', 86, 1, 0),(88, 25, '2017-05-05', 87, 1, 0),(89, 26, '2017-05-05', 88, 1, 0),(90, 43, '2017-05-05', 89, 1, 0)");
$sql= mysqli_query($splink,"INSERT INTO `COMPETITION_DATEID` (`keyid`, `COMPETITION_ID`, `DATE`, `ORDER_ID`, `HeatorFinal`, `EVENTTIME`) VALUES (91, 56, '2017-05-05', 90, 1, 0),(92, 54, '2017-05-05', 91, 1, 0),(93, 52, '2017-05-05', 92, 1, 0),(94, 55, '2017-05-05', 93, 1, 0),(95, 53, '2017-05-05', 94, 1, 0),(97, 51, '2017-05-31', 95, 1, 1400)");
$finishinitalDB="Done";
} 



 ?><p>&nbsp;</p>
<?=$txtbeforework?>

<form action="firstrun.php" method="post">
    
STEP 1.
    <input type="submit" name="initaldatabase" value="<?=$txtinitaldatabase?>">
</form>
<?=$finishinitalDB?>

STEP 2.
<?php
	if (isset($_POST['submitaddnewstaff'])){
    $password = password_hash($_POST['password'],PASSWORD_BCRYPT);
    $STAFFCODE=$_POST['STAFFCODE'];
    $STAFFUID = $_POST['STAFFUID'];
    $CH_NAME=$_POST['CH_NAME'];
    $EN_NAME=$_POST['EN_NAME'];
    $stafftitle = $_POST['stafftitle'];
		$sql= mysqli_query($splink,"INSERT INTO teacherinfo ( `STAFFCODE`,`STAFFUID`,`CH_NAME`,`EN_NAME`,`stafftitle`,`password`) VALUES (\"".$STAFFCODE."\",\"".$STAFFUID."\",\"".$CH_NAME."\",\"".$EN_NAME."\",\"".$stafftitle."\",\"".$password."\")");
		echo $txtsuccessaddnewstaff;
	}
?>
    	<p><?=$txtfirststaff?></p>
        <form action="firstrun.php" method="post">
 
        <input type="hidden" name="usersetting" value="1" />
        <input type="hidden" name="system" value="1" />
      	<table border="1">
            <tr>
            <td><?=$txtwstaffcode?><br />：</td><td><input type="text" name="STAFFCODE" value="" /></td>
            </tr>
            <td width="100"><?=$txtstaffuid?>(login ID)：</td><td><input type="text" name="STAFFUID" value="" /></td>
            </tr><tr>
            <td width="200"><?=$txtchname?>：</td><td><input type="text" name="CH_NAME" value="" /></td>
            </tr><tr>
            <td width="200"><?=$txtenname?>：</td><td><input type="text" name="EN_NAME" value="" /></td>
            </tr><tr>
            <td width="200"><?=$txtnoticetitle?>：</td><td><input type="text" name="stafftitle" value="" /></td>
            </tr><tr>
            <tr>
            <td width="50"><?=$txtpassword?>：</td><td><input type="password" name="password" value="" /></td>
            </tr>
		</table><input type="submit" name="submitaddnewstaff" value="<?=$txtsave?>" />
        <input type="submit" name="cancel" value="<?=$txtcancel?>" />
        </form>
		<p>

  STEP 3.
  從伺服器移除此檔案。Remove this file in the Server.
	<?php		

	//完成新增職員資料