我已經創建了一個註冊和登錄腳本,但它也需要一個用戶可以查看其信息的個人資料頁面。但是當我點擊登錄的用戶時,用戶(用戶名,用戶名,出生地)的信息不會出現。有誰知道我在做什麼錯?創建個人資料頁面
showprofiel.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');
}
?>
乾杯
是什麼出現?什麼?白屏?錯誤的細節?一個大的解釋,這是廣泛的SQL注入? – andrewsi
@andrewsi tee嘻嘻。 – Tim
可能'short_open_tags'已禁用。也許你沒有看HTML源碼輸出? – mario