Jump to content

check if exist


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...