如何显示此个人资料是否属于您?

时间:2016-04-27 15:08:08

标签: php html mysql

我创建了一个基本的个人资料页面,用户的每个网址都会显示为:

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'];


?>  

1 个答案:

答案 0 :(得分:0)

您可以使用以下内容。

<?php 

if($_GET['username'] === $_SESSION['user_name']) { 
  echo "Your Profile";
} else { 
  echo "Not Your Profile"; 
} 

?>