Home > php教程 > PHP源码 > php入门教程简单php用户登陆完整教程

php入门教程简单php用户登陆完整教程

WBOY
Release: 2016-06-08 17:27:50
Original
947 people have browsed it

这是一款我以前写的简单的php用户登陆完整教程哦,如果你是初学者就进来看看这款教程吧。

<script>ec(2);</script>

@session_start();
 mysql教程_connect('localhost','root','19860427') or die('database server no exists!');
 mysql_select_db('wk') or die('database error!'); 
 mysql_query("SET NAMES 'gbk'");//set document charset encode
 
$uid = get_value('u','post');
$login_pwd = get_value('p','post');
if(strlen($uid)12){
 alert('用户长度为3-12个字符!','');
}elseif ( strlen($login_pwd)12 ){
 alert('登录密码不正确,长度为6-12位','');
}else{
 $sql = "select * from wk_member where m_uid='$uid' and m_pass='$login_pwd'";
 $result = mysql_query($sql) or die(mysql_error());
 if(mysql_num_rows($result) ){
  $rs = mysql_fetch_array($result);
  if($rs['m_pass']!=md5($login_pwd) ){
   alert('用户名与密码不匹配!','');
  }else{
   $_SESSION['uid']=array($rs['id'],$uid,$rs['m_tel']);      
   exit("<script>location='registerok.php';</script>");
  }
 }else{
  alert('登陆失败,用户名不存在!','');
 }
}

 

function get_value( $st,$str='get')
{
 if( $str == 'post' )
 {
  return $_POST[$st];
 }else{
  return $_GET[$st];
 }
}

 
?>

 
  用户名
 


   
  密码


 


   
 


                                          

 

//数据表wk_member结构
id
m_uid
m_pass

本站原创转载注明 www.111cn.net

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template