这是一款我以前写的简单的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