Welcome Guest, Not a member yet? Register   Sign In
Update email only if the email doesn't exist in the database
#2

(This post was last modified: 03-04-2015, 06:35 PM by silentium.)

Add a hidden form field named 'original_email' and set the value to the users email. This field will be used as reference to detect if the users has changed the email when saving.

In the form validation PHP code we only add the unique form validation if needed.

PHP Code:
// We do the unique check only if the email field to not match the original email
if ($this->input->post('email') != $this->input->post('original_email')) {
    
$this->form_validation->set_rules('email''Email''trim|required|xss_clean|is_unique[users.email]'); 

Reply


Messages In This Thread
RE: Update email only if the email doesn't exist in the database - by silentium - 03-04-2015, 06:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB