关于PHP网站出现的 Notice: Undefined index: cd_password in
Notice:Undefinedindex:cd_passwordinD:\htdocs\djphp\include\cxjw.inc.phponline3以下是代码,希...
Notice: Undefined index: cd_password in D:\htdocs\djphp\include\cxjw.inc.php on line 3
以下是代码,希望高手给解答下!谢谢了
<?php
if(($_COOKIE['cd_name']<>'')||($_COOKIE['cd_password']<>'')){
$userid=$_COOKIE['cd_id'];
$username=$_COOKIE['cd_name'];
$password=$_COOKIE['cd_password'];
global $db;
$userlogintime=file_get_contents(_CXJW_ROOT_.'data/userlogintime.txt');
$deltime = $userlogintime -cd_onlinehold;
if(time()-$userlogintime>cd_onlinehold){
$db->query('delete from '.tname('session')." where (cd_logintime < '$deltime')");
fwrite(fopen(_CXJW_ROOT_.'data/userlogintime.txt','wb'),time());
}
$cd_ids= $db->Getone('select cd_id from '.tname('session')." where cd_uid=$userid and cd_uname='$username'");
if($cd_ids){
$db->query('update '.tname('session')." set cd_logintime='".time()."' where cd_uid=$userid");
$sql='select * from '.tname('user')." where cd_lock=0 and cd_id=$userid and cd_name='$username' and cd_password='$password'";
$result=$db->query($sql);
if($row=$db->fetch_array($result)){
$userlogined='true';
$cxjw_com_userid=$row['cd_id'];
$cxjw_com_username=$row['cd_name'];
$cxjw_com_nicheng=$row['cd_nicheng'];
$cxjw_com_password=$row['cd_password'];
$cxjw_com_photo=$row['cd_photo'];
$cxjw_com_skin=$row['cd_skin'];
$cxjw_com_sex=$row['cd_sex'];
$cxjw_com_qq=$row['cd_qq'];
$cxjw_com_email=$row['cd_email'];
$cxjw_com_sign=$row['cd_sign'];
$cxjw_com_birthday=$row['cd_birthday'];
$cxjw_com_birthprovince=$row['cd_birthprovince'];
$cxjw_com_birthcity=$row['cd_birthcity'];
$cxjw_com_resideprovince=$row['cd_resideprovince'];
$cxjw_com_residecity=$row['cd_residecity'];
$cxjw_com_hits=$row['cd_hits'];
$cxjw_com_money=$row['cd_money'];
$cxjw_com_rank=$row['cd_rank'];
$cxjw_com_friendnum=$row['cd_friendnum'];
$cxjw_com_messagenum=$row['cd_messagenum'];
$cxjw_com_loginnum=$row['cd_loginnum'];
$cxjw_com_points=$row['cd_points'];
$cxjw_com_credit=$row['cd_credit'];
$cxjw_com_grade=$row['cd_grade'];
$cxjw_com_vipindate=$row['cd_vipindate'];
$cxjw_com_vipenddate=$row['cd_vipenddate'];
$cxjw_com_weblock=$row['cd_weblock'];
}else{
$userlogined='false';
$cxjw_com_grade=0;
setcookie('cd_id','',time()-3600,cd_cookiepath);
setcookie('cd_name','',time()-3600,cd_cookiepath);
setcookie('cd_password','',time()-3600,cd_cookiepath);
}
}else{
$userlogined='false';
$cxjw_com_grade=0;
setcookie('cd_id','',time()-3600,cd_cookiepath);
setcookie('cd_name','',time()-3600,cd_cookiepath);
setcookie('cd_password','',time()-3600,cd_cookiepath);
}
}
?> 展开
以下是代码,希望高手给解答下!谢谢了
<?php
if(($_COOKIE['cd_name']<>'')||($_COOKIE['cd_password']<>'')){
$userid=$_COOKIE['cd_id'];
$username=$_COOKIE['cd_name'];
$password=$_COOKIE['cd_password'];
global $db;
$userlogintime=file_get_contents(_CXJW_ROOT_.'data/userlogintime.txt');
$deltime = $userlogintime -cd_onlinehold;
if(time()-$userlogintime>cd_onlinehold){
$db->query('delete from '.tname('session')." where (cd_logintime < '$deltime')");
fwrite(fopen(_CXJW_ROOT_.'data/userlogintime.txt','wb'),time());
}
$cd_ids= $db->Getone('select cd_id from '.tname('session')." where cd_uid=$userid and cd_uname='$username'");
if($cd_ids){
$db->query('update '.tname('session')." set cd_logintime='".time()."' where cd_uid=$userid");
$sql='select * from '.tname('user')." where cd_lock=0 and cd_id=$userid and cd_name='$username' and cd_password='$password'";
$result=$db->query($sql);
if($row=$db->fetch_array($result)){
$userlogined='true';
$cxjw_com_userid=$row['cd_id'];
$cxjw_com_username=$row['cd_name'];
$cxjw_com_nicheng=$row['cd_nicheng'];
$cxjw_com_password=$row['cd_password'];
$cxjw_com_photo=$row['cd_photo'];
$cxjw_com_skin=$row['cd_skin'];
$cxjw_com_sex=$row['cd_sex'];
$cxjw_com_qq=$row['cd_qq'];
$cxjw_com_email=$row['cd_email'];
$cxjw_com_sign=$row['cd_sign'];
$cxjw_com_birthday=$row['cd_birthday'];
$cxjw_com_birthprovince=$row['cd_birthprovince'];
$cxjw_com_birthcity=$row['cd_birthcity'];
$cxjw_com_resideprovince=$row['cd_resideprovince'];
$cxjw_com_residecity=$row['cd_residecity'];
$cxjw_com_hits=$row['cd_hits'];
$cxjw_com_money=$row['cd_money'];
$cxjw_com_rank=$row['cd_rank'];
$cxjw_com_friendnum=$row['cd_friendnum'];
$cxjw_com_messagenum=$row['cd_messagenum'];
$cxjw_com_loginnum=$row['cd_loginnum'];
$cxjw_com_points=$row['cd_points'];
$cxjw_com_credit=$row['cd_credit'];
$cxjw_com_grade=$row['cd_grade'];
$cxjw_com_vipindate=$row['cd_vipindate'];
$cxjw_com_vipenddate=$row['cd_vipenddate'];
$cxjw_com_weblock=$row['cd_weblock'];
}else{
$userlogined='false';
$cxjw_com_grade=0;
setcookie('cd_id','',time()-3600,cd_cookiepath);
setcookie('cd_name','',time()-3600,cd_cookiepath);
setcookie('cd_password','',time()-3600,cd_cookiepath);
}
}else{
$userlogined='false';
$cxjw_com_grade=0;
setcookie('cd_id','',time()-3600,cd_cookiepath);
setcookie('cd_name','',time()-3600,cd_cookiepath);
setcookie('cd_password','',time()-3600,cd_cookiepath);
}
}
?> 展开
3个回答
展开全部
下面这样的语句就会报告你说的错误,这是写程序的人对自己的要求没有达到行业高度造成的,PHP认为这个语句有缺陷:
if(($_COOKIE['cd_name']<>'')||($_COOKIE['cd_password']<>'')){
优秀程序应该这样编写:
if((isset($_COOKIE['cd_name']) && $_COOKIE['cd_name']<>'')||(isset($_COOKIE['cd_password']) && $_COOKIE['cd_password']<>'')){
但是,如果你网站大量存在类似语句,没办法一时间全部修改,可以修改php.ini文件,让它不显示错误,修改为下面这样就可以:
error_reporting = E_ALL
if(($_COOKIE['cd_name']<>'')||($_COOKIE['cd_password']<>'')){
优秀程序应该这样编写:
if((isset($_COOKIE['cd_name']) && $_COOKIE['cd_name']<>'')||(isset($_COOKIE['cd_password']) && $_COOKIE['cd_password']<>'')){
但是,如果你网站大量存在类似语句,没办法一时间全部修改,可以修改php.ini文件,让它不显示错误,修改为下面这样就可以:
error_reporting = E_ALL
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询