Jump to content

A Bit Of Form Validation Problem


23.12.2012
 Share

Recommended Posts

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

THEN
echo an error message

IF the code is found in the database

THEN
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:

if(!empty($result)) {		// Do something}if(empty($result)) {	// Do something}

Edited by 23.12.2012
Link to comment
Share on other sites

And if the number of rows is equal to 0, display the error, right? I'll give it a try, thanks a lot!Later Edit:Ok, I was getting a lot of errors, so I rewrote it, and I've included the mysqli_num_rows() function. It works great. Thanks a lot! Again. :)

Edited by 23.12.2012
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...