Ok, so my site has a link where you can search up users and go to their profile. You type a username and on the next page, it tells you if the username exists or not, and gives you a link. I think I have coded everything correctly, but apparently not.
Here is what happens: (my website echoes two pages, one if you are logged in and one if you are not logged in). If you are logged in AND you type a real username, then it will correctly display the text I want it to and the link. However, if you type a fake username when logged in, it just says the default text, not the text I necessarily want for this page.
When you are not logged in, it only displays the default text, no matter what you type.
Can someone help me and look at this code?
Default text for displaytext:
$displaytext = "Error";
$srstrSQL = "SELECT * FROM Users_For_CoinAwards WHERE Username = '$usersearched'";
$rs3 = mysql_query($srstrSQL, $connection);
while($row3 = mysql_fetch_array($rs3)){
if ($row3['Username'] == $usersearched)
{
$displaytext = "The user " . $row3["Username"] . " has been found. Please click on the below link to visit their profile.";
$displaylink = "<a href='http://www.coinawards.net63.net/user/" . $row3['Username'] . ".php' id='displaylink'>" . $row3['Username'] . "</a>";
}
else
{
$displaytext = "Sorry, the user " . $row3["Username"] . " was not found. Please check your query and try again.";
}
}
$row3 = mysql_fetch_array($rs3); print_r($row3);
Ok, and here is the part where it displays the text:
‘ . $displaytext . ‘
I double checked to make sure that the code above is the same if you are logged in or not, however the results still differ.
EDIT:
you can see what his happening for yourself at http://www.coinawards.net63.net/
Just click on the yellow ‘User Search’ button and type in a wierd random assortment of characters.
It will take you to the new page with the code below.
Ok, try this. And please try $row[] with double or single quotes, you are mixing the two.