Well... I've come across a problem I can't seem to be able to find a fix for. I've been struggling for an hour now.
I've got this database, and a web form. The web form allows me to enter a unique code somebody has been provided with, and, when I submit the form, the user has to be erased from the database. This part works, but because I can't keep track of the codes in the database, I've written a test condition so that,
IF the code is not found in the database
The problem is that it does not test correctly. Whether I don't enter anything, or the code does not exist, I get the confirmation message instead of the error one. I've tried with if($result), isset and empty, but none of them worked. Here is my code:
I've got this database, and a web form. The web form allows me to enter a unique code somebody has been provided with, and, when I submit the form, the user has to be erased from the database. This part works, but because I can't keep track of the codes in the database, I've written a test condition so that,
IF the code is not found in the database
THEN echo an error message
IF the code is found in the databaseTHEN go ahead and remove the user
The problem is that it does not test correctly. Whether I don't enter anything, or the code does not exist, I get the confirmation message instead of the error one. I've tried with if($result), isset and empty, but none of them worked. Here is my code:
Code:
if(!empty($result)) {
// Do something
}
if(empty($result)) {
// Do something
}