</button>
							<button type="button" class="btn btn-default">
								清空
							</button>
						</div>
					</form>
				</div>
			</div>
	</body>
</html>
<?php
	$sql = "Select * from teacinfo where Id like '" . $teacherID . "'";
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result, MYSQL_ASSOC);
	$teacherName=$row['Name'];
	if(isset($_REQUEST['answer'])){
		$sql="UPDATE `compsci`.`queslib` SET `question`='".$_REQUEST['Question']."',`describe`='".$_REQUEST['Describe']."',`answer`='".$_REQUEST['answer']."',`solved`=0,`teacher`='".$teacherID."',`dateout`='".date('Y-m-d')."',`character`='".$_REQUEST['Charapter']."' WHERE `queslib`.`Id`=".$_GET['id'];
		$result=mysql_query($sql);
		if($result){
			$sql="SELECT * FROM teacinfo WHERE Id LIKE '".$teacherID."'";
			$result=mysql_query($sql);
			$row=mysql_fetch_array($result,MYSQL_ASSOC);
			$to = $row['email'];
			sendMailToTeacher($to, $_REQUEST['Question'],$teacherName);
			echo '<script>alert("修改成功!");location.replace(location.href);</script>';
		}
		else{
			echo '<script>alert("修改失败!");location.replace(location.href);</script>';
		}	
	}
?>
$row=mysql_fetch_array($result,MYSQL_ASSOC);
$studentID=$row['Id'];
?>
<?php
if (isset($_REQUEST["Class"]) && isset($_REQUEST["Charapter"]) && isset($_REQUEST["Question"]) && isset($_REQUEST["Describe"])) {
	$sql="SELECT * FROM teacinfo WHERE Name LIKE '".$_REQUEST['Experiment']."' AND  Class LIKE '".$_REQUEST['Class']."'";
	$result = mysql_query($sql);
	$row0 = mysql_fetch_array($result, MYSQL_ASSOC);
	$teacherID=$row0['Id'];
	$sql = "INSERT INTO `compsci`.`queslib` 
	(`Id`, `question`, `describe`, `answer`, `solved`, `stuid`, `teacher`, `dateput`, `dateout`, `class`, `character`)
	 VALUES
	  (NULL, '" . mysql_real_escape_string($_REQUEST["Question"])."','". mysql_real_escape_string($_REQUEST["Describe"])."',NULL,0,".$studentID.",'".$teacherID."','".date('Y-m-d')."',NULL,'" . $_REQUEST["Class"] . "','".$_REQUEST["Charapter"]."');";
	$result = mysql_query($sql);
	if ($result) {
		sendMailToTeacher($row0['email'], $_REQUEST['Question'], $_REQUEST["Experiment"]);
		echo '<script>alert("提交成功,正在跳转至主页...")</script>';
		die("<script>setTimeout(window.location=\"mainpage.php\",3)</script>");
	}
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>
			计算机科学答疑系统
		</title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>