>  기사  >  백엔드 개발  >  php中的登陆login,php登陆login_PHP教程

php中的登陆login,php登陆login_PHP教程

WBOY
WBOY원래의
2016-07-12 08:50:011922검색

php中的登陆login,php登陆login

Login

<?<span>php 
</span><span>require</span> "../include/DBClass.php"<span>; 
</span><span>$username</span>=<span>$_POST</span>['UserName'<span>]; 
</span><span>$password</span>=<span>$_POST</span>['Password'<span>]; 
</span><span>if</span>(<span>empty</span>(<span>$username</span>) || <span>empty</span>(<span>$password</span><span>)){ 
  Go_Msg(</span>"请填写用户名,密码!","../default.html"<span>); 
  </span><span>exit</span><span>; 
 } 
DBConn(); 
</span><span>$password</span>=<span>md5</span>(<span>$password</span><span>); 
</span><span>$SQL</span> = "Select UserName,UserType,UserPass From siteuser where UserName='" . <span>$username</span> ."' and UserPass='" . <span>$password</span> . "' and isopen=1"<span>; 
</span><span>//</span><span>echo "$SQL"; </span>
<span>$result</span> = <span>$db</span> -> exec_SQL(<span>$SQL</span><span>); 
 </span><span>$total</span>=<span>mysql_num_rows</span>(<span>$result</span><span>); 
 </span><span>if</span>(<span>$total</span>==0<span>){ 
  DBClose(); 
  Go_Msg(</span>"注册用户还没有通过管理员审核或用户名及密码不符!请重新输入!","../default.html"<span>); 
  </span><span>exit</span><span>; 
 }</span><span>else</span><span>{ 
  </span><span>$Rs</span> = <span>$db</span> -> fetch_array(<span>$result</span><span>); 
  </span><span>//</span><span>附值,并登录 </span>
  <span>session_register</span>("username"<span>); 
  </span><span>session_register</span>("usertype"<span>); 
  </span><span>$_SESSION</span>["usertype"]=<span>$Rs</span>['UserType'<span>]; 
  </span><span>$_SESSION</span>["username"]=<span>$username</span><span>; 
  </span><span>//</span><span>echo $_SESSION["username"]; </span>
  <span>if</span> (<span>$_SESSION</span>["usertype"]==1<span>){ 
    Go_Msg(</span>"登陆成功!","default.php"<span>); 

    </span><span>//</span><span>header('Location:http://163.com'); </span>
<span>  } 
  </span><span>if</span> (<span>$_SESSION</span>["usertype"]==2<span>){ 
     Go_Msg(</span>"登陆成功!","../user2/default_1.php"<span>); 
  } 
  </span><span>if</span> (<span>$_SESSION</span>["usertype"]==3<span>){ 

     Go_Msg(</span>"登陆成功!","../user3/default_2.php"<span>); 
  } 
  </span><span>//</span><span> header('Location:default.php'); </span>
<span> } 
DBClose(); 
</span><span>//</span><span> 何问起 hovertree.com</span>
?>  

推荐:http://www.cnblogs.com/roucheng/p/phpdongtai.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1135180.htmlTechArticlephp中的登陆login,php登陆login Login ? php require "../include/DBClass.php" ; $username = $_POST ['UserName' ]; $password = $_POST ['Password' ]; if ( empty ( $username ) ||...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.