登録とログインのスクリプトを作成しましたが、ユーザーが自分の情報を確認できるプロファイル ページも必要です。しかし、ログインしているユーザーをクリックすると、ユーザーの情報 (ID、ユーザー名、出生) が表示されません。誰かが私が間違っていることを知っていますか????
showprofile.php
<?php
include("../includes/connection.php");
$id = $_GET['id'];
?>
<html>
<head>
<title>User</title>
</head>
<body>
<?php
$qry = "SELECT * FROM users WHERE id='".$id."'";
$resultaatQry = mysql_query($qry);
$resultaat = mysql_fetch_array($resultaatQry);
?>
id: <?=$id?>
<br>
username: <?=$resultaat['username']?>
<br>
birth: <?=$resultaat['birth']?>
<br>
</body>
</html>
user.php
<?php
// Inialize session
session_start();
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}
?>
<html>
<head>
<title>Secured Page</title>
</head>
<body>
<?php
$qry = "SELECT *
FROM users
WHERE id='".$id."'";
$resultaatQry = mysql_query($qry);
$resultaat = mysql_fetch_array($resultaatQry);
echo("Hallo <a href='showprofiel.php?id=".$resultaat['id']."'>".$_SESSION['username']."</a>");
echo("<br>");
?>
<br>You can put your restricted information here.</p>
<a href="../nieuws/nieuwsadmin.php">+ Nieuwsadmin</a>
<br>
<a href="logout.php">+ Logout</a>
</body>
</html>
loginproc.php
<?php
// Inialize session
session_start();
// Include database connection settings
include('../includes/connection.php');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM users WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
$_SESSION['id'] = $_GET['id'];
// Jump to secured page
header('Location: securedpage.php');
}
else
{
// Jump to login page
header('Location: index.php');
}
?>
乾杯