我创建了一个基本的个人资料页面,其中用户的每个 URL 将显示为:
profile?username=Joe.Bills
但是,我想知道当您在个人资料上时如何显示该个人资料是否是您的。我已经尝试过,但这不起作用:
<?php if($uprofile['user_name'] && $_SESSION['user_name']){ echo "Your Profile";
} else { echo "Not Your Profile"; }
?>
我知道它使用 MySQL,我应该去 PDO,但这只是为了小用途。
这是输入个人资料信息的方式:
<?php
$name = $_REQUEST['username'];
$profile = mysql_query("SELECT * FROM users WHERE user_name='$name'");
$uprofile = mysql_fetch_assoc($profile);
$username = $uprofile['user_name'];
$full = $uprofile['full_name'];
$image = $uprofile['image'];
?>
最佳答案
您可以使用以下内容。
<?php
if($_GET['username'] === $_SESSION['user_name']) {
echo "Your Profile";
} else {
echo "Not Your Profile";
}
?>
关于php - 如何显示该个人资料是否是您的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36893790/