The value of the two problematic session variables I get are NULL after passing all 3 if statements.
the login session variable works fine, it changes to true. I’ve tried removing the first appearance of the two problematic session variables, but those two variables stopped existing once I did that.
<?php
session_start();
include("sambungan.php");
$_SESSION["login"] = false;
$_SESSION["nama_pengguna"] = NULL; #Problem
$_SESSION["kata_laluan"] = NULL; #Problem
if ($_POST) {
$nama_pengguna = $_POST["nama_pengguna"];
$kata_laluan = $_POST["kata_laluan"];
if (isset($_POST["daftar"])) {
$sql = "INSERT INTO urusetia (nama_pengguna,kata_laluan) VALUES ('$nama_pengguna','$kata_laluan')";
$result = mysqli_query($sambungan,$sql);
if ($result) {
$_SESSION["login"] = true;
$_SESSION["nama_pengguna"] = $nama_pengguna; #Problem
$_SESSION["kata_laluan"] = $kata_laluan; #Problem
$_POST = array();
header("Location:./hakim.php");
die();
}
}
...