I have a web forum whereby only some selected users are allowed access to it i.e they must have $_SEESION['username'] on.
Now on the profile page – which looks like this
http://127.0.0.1/mysite/profile.php?username=john
I want to display either an upload button or an edit profile button,
depending on if they have an image uploaded.
I’m checking to see if $_GET is set, first then if not it redirects to
the homepage:
if(isset($_GET['username'])) {
$username = mysql_real_escape_string($_GET['username']);
$profile = mysql_query(SELECT *
FROM forum
WHERE username = '$username') or DIE(mysql_error());
$row = mysql_fetch_array($profile);
echo"
Name : $row[name];
Country : $row[country];
if($_GET['username'] == $_SESSION['username'] && $row['imagepath'] == '') {
echo "Upload Button";
}
else {
echo"Edit Button";
}
}
Upload Button is shown on the screen, when actually there’s an image
path specified.
Please where I’m I going wrong.
You should put double quotes around your mysql_query-parameter. I copied your code and that was my solution.
You echo too much by the way. It should be as the following code.