hi every one, am having a bit of an issue in my already exist profile page.
The thing is if a user checks his/her profile page to reedit their profile and click save the already exist code will kick in not allowing the user to save and showing the already exist error msg for the email instead of just ignoring and should only work if the user tries to change his/her email to another email that already exist to show the error hope u understand below is the code i wrote up funny thing the code works in a weird way if i try inserting the 1st email in the column that isnt mine i get already exist but if i try others it get updated
$query = "SELECT email FROM " . $DBPrefix . "users WHERE id = id IN (SELECT id FROM " . $DBPrefix . "users
WHERE email = :email)";
$params = array();
$params[] = array(':email', $system->cleanvars($_POST['TPL_email']), 'str');
$db->query($query, $params);
if ($db->numrows() > 0)
{
$ERR = $ERR_115; // E-mail already used
}
If you mean that the phone column can be blank, if the user attempts to change their phone number to a blank then obviously you cannot check for duplicates in that column. You would just need to modify your code to not run the query for any columns that are blank.
Just check to see whether $_POST['TPL_phone'] is null, and don’t run the query if it is. Same for any other column that can be empty / blank / duplicated.
Hard to offer any assistance with this kind of feedback. Could you show the code you added for checking if the variable is blank?
It would do, if your update query only specifies the new values for the columns that have changed. I thought the problem you were having here was in the duplicate-check prior to committing the profile update?
As with the other code (the phone number) that you posted, if you allow blanks in these columns, then these queries will return results. So if blanks are the only type of duplicates allowed, don’t run these checks when the entry is blank. Or run the checks, but only trigger your error code if there are results and the data to check is not blank.