在标题中,我的脚本在重新加载页面后丢失了数据或连接(我不确定)。会话保持不变。 我的网站看起来像这个方案https://i.stack.imgur.com/lssv2.jpg
部分是波兰语,所以我给译文: Hasło=密码 logowanie =记录
这里是index.php代码,它发生了......
session_start();
if ((isset($_SESSION['logged']))) {
require "panel.php";
} else {
if ((!isset($_POST['login'])) || (!isset($_POST['haslo']))) {
require "logowanie.php";
} else {
require "config.php";
$db = mysqli_connect($dbh, $dblog, $dbpass, $dbn);
$login=$_POST['login'];
$haslo=md5($_POST['haslo']);
$login=htmlentities($login, ENT_QUOTES, "UTF-8");
$haslo=htmlentities($haslo, ENT_QUOTES, "UTF-8");
$query="SELECT * FROM `rej_obywatele` WHERE `login`='".$login."' AND `haslo`='".$haslo."'";
$result = mysqli_query($db,$query);
$userid = mysqli_fetch_array($result);
if ($result) {
$numrows = mysqli_num_rows($result);
if ($numrows==1) {
$_SESSION['logged']=true;
$_SESSION['id']=$userid['id'];
echo session_id();
require "panel.php";
} else {
require "logowanie.php";
echo "<h3>FALSE LOGIN OR PASSWORD</h3>";
}
}
}
}
这是panel.php
session_start();
if (!isset($_SESSION['logged'])){
header('Location:index.php');
} else {
require "config.php";
$query="SELECT * FROM `rej_obywatele` WHERE `id`='".$_SESSION['id']."'";
$result = mysqli_query($db,$query);
$user = mysqli_fetch_array($result);
echo $user['imie']." ".$user['nazwisko']; //I cant see it after reload
我认为它与index.php中的isset有关,但我不知道如何修复它,因为很多小时:/