提供一款可以保存用戶登陸的信息來做了,這裡就是一個簡單的php 登陸並設置cookie代碼哦,很簡單的。
if(!$c_log){
$title.='登陸';
if($_SERVER['REQUEST_METHOD']=='POST'){
if(isset($_POST['username']) && trim($_POST['username'])!='' && isset($_POST['password']) && trim($_POST['password'])!=''){
$username=trim($_POST['username']);
$password=enc_p(trim($_POST['password']));
$q_author=sprintf('select * from %s where username=%s and password=%s', $dbprefix.'member', SQLString($username, 'text'), SQLString($password, 'text'));
$author=mysql_query($q_author) or die('');
$r_author=mysql_fetch_assoc($author);
if(mysql_num_rows($author)>0){
if($r_author['status']==0 || $r_main['veri']>0){
$uSQL=sprintf('update %s set visit=visit+1, visitdate=%s where id=%s', $dbprefix.'member', time(), $r_author['id']);
$result=mysql_query($uSQL) or die('');
session_unset();
session_start();
$_SESSION['palu_id']=$r_author['id'];
if(isset($_POST['remember']) && $_POST['remember']=='1'){
setcookie('palu_u', $username, time()+86400*30);
setcookie('palu_p', $password, time()+86400*30);
}else{
setcookie('palu_u','',time());
setcookie('palu_p','',time());
}
}else{
$e=1;
}
}else{
$e=2;
}
mysql_free_result($author);
}
if(isset($_GET['m']))$u[]='m='.$_GET['m'];
if(isset($_GET['t']))$u[]='t='.$_GET['t'];
if(isset($_GET['page']))$u[]='page='.$_GET['page'];
if(isset($e))$u[]='e='.$e;
$topinfo.='<script type="text/JavaScript">location.href=''.(isset($u)?'?'.join('&', $u):'./').'';</script>';
}else{
if(isset($_GET['e'])){
if($_GET['e']==2){
$msg='用戶名/密碼錯誤!';
}elseif($_GET['e']==3){
$msg='注冊成功!請'.($r_main['veri']>0?'登陸':'等待管理員審核').'。';
}else{
$msg='您的帳號還沒有通過審核,請稍候再試。';
}
}
$content.='<div class="tcontent">'.(isset($msg)?'<div class="msg_v">'.$msg.'</div>':'').'<div class="title">登陸</div><div class="lcontent"><form method="post" action="" onsubmit="return chklog();"><div class="formline"><label for="formname">用戶名:</label><input name="username" id="formname" size="32" maxlength="20" /></div><div class="formline"><label for="formpw">密 碼:</label><input name="password" id="formpw" size="32" maxlength="20" type="password" /></div><div class="formline"><label></label><input name="remember" value="1" type="checkbox" title="為了確保信息安全,請不要在網吧或者公共機房選擇此項!如果今後要取消此選項,只需點擊“退出登陸”即可。" />記住我</div><div class="formline"><input type="submit" value="登陸" id="formsubmit" class="button" /> <input type="reset" value="取消" class="button" /><br/>'.($r_main['openreg']==0?'<a href="?m=reg">加入本班</a> | ':'').'<a href="?m=lostpw">忘記密碼</a></div></form></div></div>';
}
}else{
$topinfo.='<script type="text/JavaScript">location.href='./';</script>';
}
?>