PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if (empty($user)) {
die("That username doesn't exist! Try making <i>$username</i> today! <a href='index.php'>← Back</a>");
}
If i type in a random user name into the usernae field it should come up with an error message which is stated above, instead the page just refreshes and there is no change taking place or any error message showing up. I have tried this line too but its not working; if ($user == '0'))
marvela wrote:I'm creating a a login system for my website and up until now it was working fine.
What changed?
Have you echoed what is contained in $user to know what you are getting (using print_r() or var_dump())? Also you should have backticks around table and field names, not single quotes.
if ($user == '0'))die("That username doesn't exist! Try making <i>$username</i> today! <a href='index.php'>← Back</a>");
}
I don't have any users stored in the database for testing purposes, i am simply trying to create a function from which a user will get a notification that a particular username doesn't exist, i have inputted a random name into the username field and when i click log in the page just refreshes and no change is taken place. I need that error message to show up on the page when a user types in a username that doesn't exist.
marvela wrote:The code which i need help on is this line
You just repeated what you said in your initial post and ignored our comments and requests! It seems pretty clear that they problem is with $user, so you need to backtrack through the code from that point and find out why that value is not being set right. Or if empty($user) is the wrong condition.