if(isset($_REQUEST["pwd"]) && isset($_REQUEST["name"]))
{
$password = $_REQUEST['pwd'];
$name = $_REQUEST['name'];
$checkUserPass = mysql_query("SELECT * FROM validPersonnel WHERE Passkey = '$password' and Name = '$name'", $conn);
if(mysql_num_rows($checkUserPass) == 1)
{
$personnelId = mysql_query("SELECT PersonnelID FROM validPersonnel WHERE Passkey = '$password' and Name = '$name'", $conn);
while($row = mysql_fetch_assoc($personnelId))
{
//echo $row['PersonnelID'];
//flush ();
var_dump($row);
}
//setcookie()
mysql_close($conn);
echo "<br/><br/>";
echo "<script>alert('Logged In.')</script>";
header("Refresh: 1; url=profile/profile.php?id="'.$row['PersonnelId'].');
//header('Refresh: 1; url=test.php?id=$personnelId');
}
else
{
echo "<br/><br/>";
echo "<script>alert('Wrong Password.')</script>";
header('Refresh: 1; url=personnelselect.php');
}
}
&GT?; 强文
我有这个代码,我希望传递给profile / profile.php $ row的值。我怎么能有效地做到这一点?请帮忙
答案 0 :(得分:1)
您可以使用Redirect
标题重定向:
https://stackoverflow.com/a/768472/421752
显然Refresh
标题有怪癖:PHP header("Refresh") problems
答案 1 :(得分:0)
您应该保存从提取返回的结果。
$pId = "";
while($row = mysql_fetch_assoc($personnelId)) {
$pId = $row['PersonnelID'];
//flush ();
var_dump($row);
}
//setcookie()
mysql_close($conn);
echo "<br/><br/>";
echo "<script>alert('Logged In.')</script>";
"Refresh: 1; url=profile/profile.php?id={$pId}"
提示:正如帖子评论中所提到的,您应该真正保护自己免受SQL注入并使用较新的mysqli
功能。
答案 2 :(得分:0)
在任何Html output
或php echo
或print
之前使用标头
你在这里
echo "<br/><br/>";
echo "<script>alert('Logged In.')</script>";
如果您将用户定向到主页,则不需要;