最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 登陆并设置cookie代码
时间:2009-04-14 编辑:简简单单 来源:一聚教程网
提供一款可以保存用户登陆的信息来做了,这里就是一个简单的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.='';
}else{
if(isset($_GET['e'])){
if($_GET['e']==2){
$msg='用户名/密码错误!';
}elseif($_GET['e']==3){
$msg='注册成功!请'.($r_main['veri']>0?'登陆':'等待管理员审核').'。';
}else{
$msg='您的帐号还没有通过审核,请稍候再试。';
}
}
$content.='
}
}else{
$topinfo.='';
}
?>
相关文章
- php 设置cookie路径例子总结 05-21
- php 设置cookie与清除cookie方法 06-30
- php 设置cookie高级用法 06-27
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31