Heim > Artikel > Backend-Entwicklung > 读写数据库的有关问题
读写数据库的问题
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> require_once("session.php"); $web_root_part = "../"; require_once($web_root_part."lib/db.php"); require_once($web_root_part."lib/function.php"); header('Content-type:text/html;charset=utf-8'); $AdminID = trim($_POST['AdminID']); $PassWord = trim($_POST['PassWord']); $Addtime = date("Y-m-d H:i:s"); $querySel = "select * from Admin where AdminID='".$AdminID."'"; if( !($result = $db->sql_query($querySel)) ) { message_die(DB_MESSAGE, 'Could not query Admin'); }else{ $row = $db->sql_fetchrow($result); //$db->sql_freeresult($result); if (empty($row['ID'])){ $sql="insert into Admin (AdminID,PassWord,Editer,Addtime) values('".$AdminID."','".md5($PassWord)."','".$_SESSION['AdminID']."','".$Addtime."')"; if( !($result = $db->sql_query($sql)) ) { //echo $sql; message_die(DB_MESSAGE, 'Could not query Admin'); }else{ echo "<script>location.replace('admin.php');</script>"; } }else{ echo "<script language="Javascript">"; echo "alert('提示:管理员ID已存在,请重新输入!');"; echo "history.go(-1);"; echo "</script>"; } } ?>