⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 validate.php

📁 PHP4_0入门与提高源程序代码
💻 PHP
字号:
<?
include "config.php";	//包含配置文件  

if ($uservalid=='')	//$uservalid为空表示没有用户登陆
    {
	//$logout为1表示用户点击了退出按钮,这时把cookie设为空
    if ($logout==1){setcookie ("uservalid", '',time()-7600); 
			?> 
			<!--把页面重定向到index.php-->
			<meta http-equiv="REFRESH" CONTENT="0;URL=index.php"> 
			<?
		}
	//从表格users中查询用户的全部信息
    $query="select * from users where user='$xxname' and password='$xxpassword'";

	//连接MySQL数据库服务器
    $mysql_link = mysql_connect($host,$user,$password);
	  mysql_select_db($bdd,$mysql_link);	//选择数据库
	  //执行上面的查询语句
	  $mysql_result = mysql_query($query, $mysql_link);
	  //把结果保存到$row数组中
	  $row = mysql_fetch_row($mysql_result);
	  	  //如果登陆成功,设置cookie
	  	  if ($row[1]!='') {setcookie ("uservalid", $xxname,time()+3600); }
	  //否则重定向至index.php
	  else { ?> <meta http-equiv="REFRESH" CONTENT="0;URL=index.php"> <? exit; } 
	 $username=$xxname;
        }
    //如果用户已经登陆
	else {
    	//注销用户,并把页面重定向到index.php
		if ($logout==1){setcookie ("uservalid", '',time()-7600); 
		?> <meta http-equiv="REFRESH" CONTENT="0;URL=index.php"> <?
		}
		$username=$uservalid;
    }
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -