我正在制作这个登录系统,但我的网站不会看到我$_SESSION
在另一个页面上输入的值。
在我的标题代码(包含在每一页上)中,我得到了:
<?php
session_start();
?>
和我的登录处理:
<?php
include("header.php");
$myusername= $_POST['naam2'];
$mypassword= $_POST['wachtwoord'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql = "SELECT * FROM winkel WHERE naam='$myusername' AND BINARY wachtwoord ='$mypassword'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if ($count == 1) {
session_register($myusername);
$inf = mysql_fetch_array($result);
$_SESSION['winkelinfo'] = $inf;
header("Location: mijntreinwinkeltje.php");
}
else {
header("location:login.php?err=1");
}
?>
然后,当我填写正确的凭据时,它会重定向到mijntreinwinkeltje.php 。然后在mijntreinwinkeltje.php我放:
<?php
include("header.php");
$winkelinfo = $_SESSION['winkelinfo'];
if ($winkelinfo)
echo("derp".$winkelinfo['naam']);
$voornaam = $winkelinfo['gebruikervoornaam'];
$achternaam = $winkelinfo['gebruikerachternaam'];
?>
但它不会打印echo("derp".$winkelinfo['naam']);
,$voornaam
并且$achternaam
都是空的。
我究竟做错了什么?