php 登陆并设置cookie代码

php 文件安装程序三

提供一款可以保存用户登陆的信息来做了,这里就是一个简单的php
登陆并设置cookie代码哦,很简单的。

$title.=’管理记录’;$content.=’ul
class=clist’;$page=(isset($_GET[‘page’])
intval($_GET[‘page’])0)?intval($_GET[‘page’]):1;$q_aop=sprintf(‘select
a.*, b.name, b.photo from %s as a, %s as b where a.aid=b.id order by
a.datetime desc’, $dbprefix.’adminop’,
$dbprefix.’member’);$a_aop=mysql_query($q_aop) or
die(”);$tr_aop=mysql_num_rows($a_aop);$tp_aop=ceil($tr_aop/$r_main[‘pagesize’]);if($page$tp_aop
$tp_aop0)$page=$tp_aop;$q_l_aop=sprintf(‘%s limit %d, %d’, $q_aop,
($page-1)*$r_main[‘pagesize’],
$r_main[‘pagesize’]);$aop=mysql_query($q_l_aop) or
die(”);$r_aop=mysql_fetch_assoc($aop);if(mysql_num_rows($aop)0){do{if(isset($_GET[‘did’])
$_GET[‘did’]==$r_aop[‘id’]){$dSQL=sprintf(‘delete from %s where
id=%s’, $dbprefix.’adminop’,
$r_aop[‘id’]);$result=mysql_query($dSQL) or
die(”);$topinfo.=’script
type=text/JavaScriptlocation.href=’?m=settingt=adminop’;/script’;}else{$content.=’li
class=l_lista href=?m=useramp;id=’.$r[‘aid’].’img
src=’.($r_aop[‘photo’]!=”?$r_aop[‘photo’]:’images/dphoto.jpg’).’
alt=’.$r_aop[‘name’].’ class=photo width=55 height=55//adiv
class=list_rdiv class=list_titlespan class=gmodimg src=images/o_2.gif
alt=删除
onclick=if(confirm(‘确认要删除?’))location.href=’?m=settingt=adminopdid=’.$r_aop[‘id’].”;
style=cursor: pointer;//span’.getalink($r_aop[‘aid’],
$r_aop[‘name’]).’nbsp;nbsp;span
class=gdate’.getldate($r_aop[‘datetime’]).’/span/divdiv
class=list_c’;if($r_aop[‘tid’]==1){$pr=getpinfo($r_aop[‘sid’]);$content.=’a
href=?m=albumamp;id=’.$r_aop[‘sid’].’img src=’.getthu($pr).’
alt=’.$pr[‘title’].’ width=70 height=70
class=al_t//abr/’;}elseif($r_aop[tid]==2){$pr=getcinfo($r_aop[‘sid’]);$content.=’a
href=?m=campamp;id=’.$r_aop[‘sid’].”.$pr[‘title’].’/abr/br/’;}$content.=gbookencode($r_aop[‘content’]).’/div/div/li’;}}while($r_aop=mysql_fetch_assoc($aop));$content.=’/ul’;if($tp_aop1)$content.=getpage($page,
$tp_aop);}else{$content.=’lidiv class=title管理记录/divdiv
class=lcontent没有记录/div/li/ul’;}mysql_free_result($aop);mysql_free_result($a_aop);

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>’;
}
?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注