根据ucenter 1.5接口手册示例进行了一些更改!
问题:
$Example_username为什么获取不到值?在用户点击登陆后跳转登陆页面(login.php)
结构为:require_once("./global_header.php");
if(!$Example_username) {
      echo '<form method="post" action="./login_save.php">
            <input type="text" name="username" class="input_style">
            <input type="password" name="password" class="input_style">
            <input type="submit" name="submit" value="登 录">
            </form>';
} else {
      echo '<script src="ucexample.js"></script><div id="append_parent"></div>';
      echo $Example_username.' <a href="'.$_SERVER['PHP_SELF'].'?example=logout">退出</a> ';
      echo ' <a href="'.$_SERVER['PHP_SELF'].'?example=pmlist">短消息列表</a> ';
      echo $newpm ? '<font color="red">New!('.$newpm.')</font> ' : NULL;
      echo '<a href="#" onclick="pmwin(\'open\')">进入短消息中心</a> ';
      echo ' <a href="'.$_SERVER['PHP_SELF'].'?example=friend">好友</a> ';
      echo ' <a href="'.$_SERVER['PHP_SELF'].'?example=avatar">头像</a> ';
}
require_once("./global_footer.php");数据提交至login_save.php页面!
结构为:require_once("./global_header.php");
      list($uid, $username, $password, $email) = uc_user_login($_POST['username'], $_POST['password']);
      setcookie('Example_auth', '', -86400);
       if($uid > 0) {
            if(!$db->result_first("SELECT count(*) FROM {$tablepre}members WHERE uid='$uid'")) {
                   $auth = rawurlencode(uc_authcode("$username\t".time(), 'ENCODE'));
                  echo '您需要激活该账号,才能进入本应用程序<br><a href="'.$_SERVER['PHP_SELF'].'?example=register&action=activation&auth='.$auth.'">继续</a>';
                   //exit;
             }
             setcookie('Example_auth', uc_authcode($uid."\t".$username, 'ENCODE'));
             $ucsynlogin = uc_user_synlogin($uid);
             //header("location: user.php?error=1"); 此句应用后没有任何效果 不跳转
             echo '<div style="font-size:12px;">登录成功'.$ucsynlogin.'<br><a href="./login.php">继续</a></div>';
             //exit;
       } elseif($uid == -1) {
             echo '用户不存在,或者被删除';
       } elseif($uid == -2) {
             echo '密码错误';
       } else {
             echo '未定义';
       }
require_once("./global_footer.php");global_header.php页面
主要结构为:include './config.inc.php';
include './include/db_mysql.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
include './uc_client/client.php';
if(!empty($_COOKIE['Example_auth'])) {
      list($Example_uid, $Example_username) = explode("\t", uc_authcode($_COOKIE['Example_auth'], 'DECODE'));
} else {
      $Example_uid = $Example_username = '';
}
$newpm = uc_pm_checknew($Example_uid);
其中还包括html页面的基本格式代码如:css样式 w3c标准 字符编码 等事件:
已实现 通讯成功
在将数据提交 login_save.php 页面显示 登陆成功 单击 继续 返回 login.php
页面 login.php 并没有显示登陆后效果,还是登陆前的状态.$Example_username 没有得到值 但是 bbs 已经实现同步登陆!其它连接文件没有改动过! 请高手帮助解决?

解决方案 »

  1.   

          list($uid, $username, $password, $email) = uc_user_login($_POST['username'], $_POST['password']);
     $uid 取到了吗?是多少?
      

  2.   


    $uid 能取到值
    是与用户表中uid相等的 >0 的值可以通过 if($uid > 0) 的判断
      

  3.   

    setcookie('Example_auth', uc_authcode($uid."\t".$username, 'ENCODE'));成功了吗?
      

  4.   

    页面没有输出任何东西!但是在我没进行更改之前是正常的!(在没添加require_once("./global_header.php"));global_header.php文件里没有对cookie进行任何操作!经我测试ucexample_2.php文件在没有更改前事正常的
    我把ucexample_2.php里面直接添加 echo "1"; 这样也出问题!这怎么解决!
      

  5.   

    setcookie前不能输入任何东西。
      

  6.   

    ...........但是我就无法设置样式了不能调用global_header.php 文件文字编码也是乱的呀! 所以global_header.php这文件时必须调用的也没有其他方法可以解决!
      

  7.   

    setcookie()后跳转到显示页面。