Jump to content

check if exist


SentiJB

Recommended Posts

 $email_check = $GLOBALS['db']->select('CubeCart_customer', array('customer_id'), array('email' => $customer['email']));
        if($email_check && $email_check[0]['customer_id']!==$_POST['customer_id'] {
            $GLOBALS['main']->errorMessage($lang['account']['error_email_in_use']);
            $customer_updated = false;
        } elseif (($GLOBALS['db']->update('CubeCart_customer', $customer, array('customer_id' => $_POST['customer_id']))) !== false) {
            if((int)$customer['status']===0) $GLOBALS['db']->delete('CubeCart_sessions', array('customer_id' => (int)$_POST['customer_id']));
            $customer_updated = true;
        }

does this check all entry in database if email exists ?

Link to comment
Share on other sites

"check all entry in database"

Generally, the "database" is the entire collection of tables (and views, procedures, etc) that an application uses, and that collection is given a name.

That said, the code above is querying just one table contained in that database.

So, all records of that specified table will be inspected to find the occurrences where 'email' contains the given value. But other tables will not be inspected.

I notice that the first "if" test is making an tight negative comparison of customer_id values. So, if they do not match, show a banner saying that the email exists.

I believe that is not your intent.

Please know that POSTed values are always given to PHP as the type "string". And, for the database result, for 'customer_id', it may be the type "integer". Thus, the tight comparison (value and data type) in the above code will fail.

Link to comment
Share on other sites

thats what i ment. Table. 

I was checking how it works when a customer wants to register with email how it's checked in customer table.

This is the code i found that's used now.

want to check the customer table for nickname if it's allready in use. 
But before i spend hours trying to get it 2 work i want to be certain its the right code 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...