VipinSaini's avatar

QueryException in Connection.php line 647: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'saini' for key 'users_email_unique'

Hello Friends, I have a simple register form where users fill their put firstname/lastname/email/password but whenever i fill same first/last name my site throws above error. However first/last name are not uniques..

Here is my controller..

    $rules = array('firstname'=>'required|alpha','lastname'=>'required|alpha','email'=>'required|email|unique:users','password'=>'required');

    $customMessage = array('firstname'=>'First Name is required','lastname'=>'Last Name is required','email'=>'Email is required','password'=>'Password is required');

    $data = Input::except(array('_token'));
    $validator = Validator::make($data,$rules,$customMessage);

    if($validator->fails()){
        return Redirect::to('register')
                ->withErrors($validator);
    }else{

        HomeModel::saveFormData($data);
        return Redirect::to('login')
                ->withMessage('Data Inserted');
    }
0 likes
8 replies
abusalameh's avatar

this error for email validation check if the email exists in the database or not

abusalameh's avatar

can you please provide me with the migration for this table ?

hbrawnak's avatar

Please delete the users table which you have created manually. And migrate the migration file. I hope, it will work fine.

Please or to participate in this conversation.