コードを読むのを手伝ってください。
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>医院门诊挂号系统</title> <style type="text/css"> #table { margin-right: auto; margin-left: auto; } </style> </head> <body style="text-align: center"> <?php $pname=$_POST['pname']; $psex=$_POST['psex']; $page=$_POST['page']; $room=$_POST['room']; if (empty($pname)||empty($psex)||empty($page)) { ?> <p style="text-align:center">请输入完整的患者信息!</p> <form method="post" action="Guahao.php"> <table id="table"> <tr> <td>姓名:</td><td><input type="text" id="pname" /></td><td>性别:</td><td><input type="text" id="psex" /></td> </tr> <tr> <td>年龄:</td><td><input type="text" id="page" /></td><td>科室:</td><td><input type="text" id="room" /></td> </tr> </table> <input type="reset" value="重置" id="reset" style="width:100px;height:20px" /> <input type="submit" value="挂号" id="submit" style="width:100px;height:20px" /> </form> <?php } else { $db = new mysqli('127.0.0.1','clinicadmin','clinicadmin','clinic'); if (mysqli_connect_errno()) { echo "无法连接数据库,请稍后重试。"; exit; } $query = "insert into guahao values ('".$pname."', '".$psex."', '".$page."', '".$room."')"; $result = $db->query($query); if (!$result) { echo"无法登陆!"; exit; } echo"<p>挂号成功!</p>"; $db->close(); ?> <a href="guahao.html">继续挂号</a> <?php } ?> </body> </html>