这是 Select 在文件中出现的唯一一次。 。 。 。
function GetUserFromEmail($email,&$user_rec)
{
if(!$this->DBLogin())
{
$this->HandleError("Database login failed!");
return false;
}
$email = $this->SanitizeForSQL($email);
$result = mysql_query("Select * from $this->tablename where email='$email'",$this->connection);
if(!$result || mysql_num_rows($result) <= 0)
{
$this->HandleError("There is no user with email: $email");
return false;
}
$user_rec = mysql_fetch_assoc($result);
return true;
}
和 . 。 .
function CheckLoginInDB($username,$password)
{
if(!$this->DBLogin())
{
$this->HandleError("Database login failed!");
return false;
}
$username = $this->SanitizeForSQL($username);
$nresult = mysql_query("SELECT * FROM $this->tablename WHERE username = '$username'", $this->connection) or die(mysql_error());
// check for result
$no_of_rows = mysql_num_rows($nresult);
if ($no_of_rows > 0) {
$nresult = mysql_fetch_array($nresult);
$salt = $nresult['salt'];
$encrypted_password = $nresult['password'];
$hash = $this->checkhashSSHA($salt, $password);
}
$qry = "Select name, email from $this->tablename where username='$username' and password='$hash' and confirmcode='y'";
$result = mysql_query($qry,$this->connection);
if(!$result || mysql_num_rows($result) <= 0)
{
$this->HandleError("Error logging in. The username or password does not match");
return false;
}
$row = mysql_fetch_assoc($result);
$_SESSION['name_of_user'] = $row['name'];
$_SESSION['email_of_user'] = $row['email'];
$_SESSION['phone_of_user'] = isset($row['phone'])?$row['phone']:'phone not set';
return true;
}
此外,这也是 $row 唯一一次出现。从其他 php 文件调用的函数如下。 。 。 .
<p id="mobilecheck" align="center"> Willkommen züruck <? echo $fgmembersite->UserFullName(); ?>! </br>
Willkommen UserPhone(); ?>! Willkommen züruck UserEmail(); ?>!
最佳答案
瑞克, 我会写在这里,以便您更好地理解。为了调试目的,请执行以下操作:
而不是
$_SESSION['phone_of_user'] = $row['phone'];
把这个:$_SESSION['phone_of_user'] = $row; //This will put an entire array in your variable
而不是:
<p id="mobilechiiieckby" align="center"> Willkommen <? echo $fgmembersite->UserPhone(); ?>! </br>
写下:
<p id="mobilechiiieckby" align="center"><pre><?php print_r($_SESSION['phone_of_user']); ?>!</pre></p>
这两个简单的修改将帮助您了解 $row 变量中的内容。看到它的内容后,您就可以玩它了。让我们在这里继续讨论,我将用新信息更新这个答案。
稍后编辑: 更新这一行:
$qry = "Select name, email from $this->tablename where username='$username' and password='$hash' and confirmcode='y'";
这个:
$qry = "Select name, email, phone from $this->tablename where username='$username' and password='$hash' and confirmcode='y'";
关于php - 使用单独的链接 php 文件获取当前 session 信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30939214/