我正在开设一个网站,其中包含用户个人资料页面。
这是我在页面顶部的代码:
<?php
require 'includes/connect.inc.php';
session_start();
$id = $_SESSION['user_id'];
$userResult = mysqli_query("SELECT * FROM users where user_id ='$id'");
while($userRow = mysqli_fetch_array($userResult)) {
$avatar = $userRow['avatar'];
$locatie = $userRow['locatie'];
$info = $userRow['info'];
$email = $userRow['email'];
$username = $userRow['username'];
}
?>
这是必须显示数据库中的行的部分(用户在他自己的个人资料页面上可以看到的部分)
<?php if(isset($_SESSION['username'])){
?>
<div class="col-lg-6">
<h4>Naam:</h4>
<p><?php echo $username; ?></p>
<h4>Locatie:</h4>
<p><?php echo $locatie; ?></p>
<h4>E-mailadres:</h4>
<p><?php echo $email; ?></p>
<h4>Informatie:</h4>
<p><?php echo $info; ?></p>
<a href="/editProfile.php">Klik hier</a> om uw profiel te bewerken.
</div>
<div class="col-lg-6">
<?php echo "<img class='useravatar' src='/avatar/user" . $id . ".jpg'></img>"; ?>
<?php
} else {
echo "U hebt geen bevoegdheid om deze pagina te bekijken";
}
?>
为什么没有显示任何内容?
这是登录表单中的验证页面:
$query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'") or die(mysql_error());
$row = mysql_num_rows($query) or die(mysql_error());
if($row == 1){
$queryFetch = mysql_fetch_array($query);
session_start();
$_SESSION['username'] = $queryFetch['username'];
$_SESSION['role'] = 'user';
$_SESSION['email'] = $queryFetch['email'];
$_SESSION['user_id'] = $queryFetch['user_id'];
if(isset($_SESSION['username'])){
header ('location: /usercp.php');
}
}
}
&GT;