<?php session_start(); header("content-type:text/html;charset=utf-8 "); require ("../config.php"); require ("../class.php"); //鏍规嵁action鍒ゆ柇 switch($_GET['action']){ //------------------鍒ゆ柇鐧婚檰------------------ case "login"; $name = $_POST['name']; $password=$_POST['password']; $sql="select name , password from user where name='$name'&& password='$password' "; $row=$db->query($sql); if($db->mysql_nums($row)){ $rult=$db->mysql_row($row); $_SESSION['name']=$rult[0]; echo $_SESSION['name']; header("Location:main.php"); }else{ echo "鐧婚檰澶辫触"; header("Location:./"); } //echo $name ; break ; //---------------------娉ㄥ唽------------------------ case "add"; //echo "book"; $name = $_POST['name']; $password = $_POST['password']; $mail = $_POST['mail']; $xie = $_POST['xie']; $diz = $_POST['diz']; $number = $_POST['number']; $db= new db ; $db->connect_db($dbhost,$dbuser,$dbpassword,$dbname) ; //insert $sql="insert into user set name='$name' , password='$password' , mail='$mail' , xie='$xie' , diz='$diz' , number=$number"; //$sql="INSERT INTO `user` SET `name`='$name', `password`='$password', `mail`='$mail', `xie`='$xie', `diz`='$diz', `number`=$number"; //echo "ok"; if($db->query($sql)){ //session_register("user"); $_SESSION['user']=$name ; //$user=$_SESSION['user']; //header("location: ".$_SERVER["HTTP_REFERER"]); header("Location:indexlogin.php"); }else{ echo "娉ㄥ唽澶辫触"; } break; //-----------------------淇敼鐢ㄦ埛-------------------- case "edituser"; //echo "book"; $id = $_POST['id']; $name = $_POST['name']; $password = $_POST['password']; $mail = $_POST['mail']; $xie = $_POST['xie']; $diz = $_POST['diz']; $number = $_POST['number']; $db= new db ; $db->connect_db($dbhost,$dbuser,$dbpassword,$dbname) ; //update $sql="update user set name='$name' , password='$password' , mail='$mail' , xie='$xie' , diz='$diz' , number=$number where id=$id"; if($db->query($sql)){ //session_register("user"); $_SESSION['user']=$name ; //$user=$_SESSION['user']; //header("location: ".$_SERVER["HTTP_REFERER"]); header("Location:./userlist.php"); }else{ echo "淇敼澶辫触"; } break; //-----------------淇敼鏂囦欢------------------- case "editfile"; //echo "book"; $id = $_POST['id']; $cat_bigId = $_POST['cat_bigId']; $cat_sId = $_POST['cat_sId']; $filename = $_POST['filename']; $textname = $_POST['textname']; //$diz = $_POST['diz']; //$number = $_POST['number']; $db= new db ; $db->connect_db($dbhost,$dbuser,$dbpassword,$dbname) ; //update $sql="update file set cat_bigId='$cat_bigId' , cat_sId='$cat_sId' , filename='$filename' , textname='$textname' where id=$id"; if($db->query($sql)){ //session_register("user"); $_SESSION['user']=$name ; //$user=$_SESSION['user']; //header("location: ".$_SERVER["HTTP_REFERER"]); header("Location:./filelist.php"); }else{ echo "淇敼澶辫触"; } break; //---------------瀹夊叏閫€鍑?------------- case "out"; session_unset(); header("Location:admin/login.php"); default: header("Location:./login.php"); } ?>