// The Login php
<?php
require("dbh.inc.php");
if (isset($_POST["login"])) {
$user_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_login"]);
$password_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password_login"]);
$sql = "SELECT `user_id` FROM `users` WHERE `user_uid` = '$user_login' AND `user_pwd` = '$password_login'";
$run_sql = mysqli_query($conn, $sql);
if(mysqli_num_rows($run_sql)==1){
while($row=mysqli_fetch_array($sql)){
$id = $row['user_id'];
}
$_SESSION["user_login"] = $user_login;
header("Location: ../main.php");
exit();
}
else
{
echo "The information is incorrect, try again";
exit();
}
}
?>
//重定向的首页标题
<?php
include("dbh.inc.php");
session_start();
if (!isset($_SESSION["user_login"])){
}else {
header("Location: ../home.php");
exit();
}
?>
<!doctype html>
<html>
<head>..............
//我正在尝试重定向的页面
<?php
include("use/header.php");
echo $_SESSION['user_login'];
?>
</body>
</html>
//但我收到“通知:未定义索引:第3行的C:\ xampp \ htdocs \ home.php中的user_login”
//请帮助
上面的代码应该显示我正在尝试做的事情...我正在尝试打印出登录到“ home.php”页面上的数据库中的帐户的用户名