- 论坛徽章:
- 0
|
下面是login.php
- session_start();
- $login = new Login();
-
- if($_SERVER['REQUEST_METHOD']=='POST')
- {
- if(!empty($_POST['clientcode'])) {
-
- if(checkSecurityCode($_POST['clientcode'])) {
- if($id=$login->CheckUser($_POST['name'],$_POST['pwd']))
- {
- $_SESSION['UID']=$id;
- $_SESSION['NAME']=$_POST['name'];
- $msg="Success!";
- header("Location:usercp.php");
- exit();
- }else{
- $msg="用户名或密码错误!请重新输入!";
- }
- } else {
- $msg="验证码错误!请重新输入!";
- }
-
- } else {
- $msg = "请输入验证码";
- }
-
- }
- function checkSecurityCode($code) {
- if(!empty($code)) {
- if($_SESSION['code'] === $code) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
复制代码
下面是index.php
- <?php
- if(isset($_SESSION['NAME'])){
- ?>
- <p>欢迎你 <?php echo $_SESSION['NAME']; ?>|<a href="logout.php">退出登陆</a></p>
- <?php
- }else{
- ?>
- <a href="login.php" target="_self">登陆</a>|<a href="reg.php" target="_self">注册</a>
- <?php
- }
- ?>
复制代码
下面是logout.php
- <?php
- session_destroy();
- header("Location:index.php");
-
- ?>
复制代码
问题是,登陆了,usercp.php页面显示成功!但是再访问index.php页面是没有显示欢迎信息!
[ 本帖最后由 Skyverd 于 2008-5-20 12:25 编辑 ] |
|