我在数据库中调用注册用户的ID时遇到问题,要显示在地址栏中。我不确定问题是什么。这是PHP代码:
在signup.php中:
if($reg_user->register($uname,$email,$upass,$code))
{
$id = $reg_user->lasdID();
$key = base64_encode($id);
$id = $key;
在verify.php中:
if(empty($_GET['id']) && empty($_GET['code']))
{
$user->redirect('login.php');
}
if(isset($_GET['id']) && isset($_GET['code']))
{
$id = base64_decode($_GET['id']);
$code = $_GET['code'];
$statusY = "Y";
$statusN = "N";
$stmt = $user->runQuery("SELECT userID,userStatus FROM tbl_users WHERE userID=:uID AND tokenCode=:code LIMIT 1");
$stmt->execute(array(":uID"=>$id,":code"=>$code));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() > 0)
{
if($row['userStatus']==$statusN)
{
$stmt = $user->runQuery("UPDATE tbl_users SET userStatus=:status WHERE
userID=:uID");
$stmt->bindparam(":status",$statusY);
$stmt->bindparam(":uID",$id);
$stmt->execute();
在我的channel.class.php中:
public function redirectchannel()
{
header('Location: index.php?id='.$userID);
}
在login.php中:
<?php
session_start();
require_once 'class.channel.php';
$user_login = new USER();
if($user_login->is_logged_in()!="")
{
$user_login->redirectchannel();
}
if(isset($_POST['btn-login']))
{
$email = trim($_POST['txtemail']);
$upass = trim($_POST['txtupass']);
if($user_login->login($email,$upass))
{
$user_login->redirectchannel();
}
}
?>
在index.php(用户的目标网页)中:
$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->bindParam(':uid', $_GET['id']);
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
在重定向时,地址栏只显示&#34; index.php?id =&#34;。 id没有被调用。