Search
 
SCRIPT & CODE EXAMPLE
 

PHP

codeigniter email validate and dublicate from database in php

// THIS HELPER METHOD CHECKS IF THE EMAIL IS VALID OR NOT. IT BASICALLY CHECKES THE DUPLICATION
function email_duplication($email = "", $user_id = "")
	{
		$CI	= &get_instance();
		$CI->load->database();

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) { //FILTER MAIL FIRST
			
			$query = $CI->db->get_where('users', ['email' => $email]);
			if (!empty($user_id)) { //IF USER-ID EXIST
				$query_result = $query->row_array();
				if ($query->num_rows() == 0 || $query_result['id'] == $user_id) { //IF NOT FIND ANY DUBLICATE
					return true;
				} else { //IF FIND
					$CI->session->set_flashdata('notice_message', get_phrase('Email_already_exists'));
					redirect($_SERVER['HTTP_REFERER'], 'refresh');
				}
			} else { //WHEN USER ID NOT EXIST
				if ($query->num_rows() > 0) { //FIND DUBLICATE
					$CI->session->set_flashdata('notice_message', get_phrase('Email_already_exists'));
					redirect($_SERVER['HTTP_REFERER'], 'refresh');
				} else { //NOT FIND
					return true;
				}
			}

		} else { //INVALID EMAIL
			$CI->session->set_flashdata('error_message', get_phrase('Invalid_email'));
			redirect($_SERVER['HTTP_REFERER'], 'refresh');
		}
		

	}
Comment

codeigniter email validate and dublicate from database in php

// THIS HELPER METHOD CHECKS IF THE EMAIL IS VALID OR NOT. IT BASICALLY CHECKES THE DUPLICATION
function email_duplication($email = "", $user_id = "")
	{
		$CI	= &get_instance();
		$CI->load->database();

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) { //FILTER MAIL FIRST
			
			$query = $CI->db->get_where('users', ['email' => $email]);
			if (!empty($user_id)) { //IF USER-ID EXIST
				$query_result = $query->row_array();
				if ($query->num_rows() == 0 || $query_result['id'] == $user_id) { //IF NOT FIND ANY DUBLICATE
					return true;
				} else { //IF FIND
					$CI->session->set_flashdata('notice_message', get_phrase('Email_already_exists'));
					redirect($_SERVER['HTTP_REFERER'], 'refresh');
				}
			} else { //WHEN USER ID NOT EXIST
				if ($query->num_rows() > 0) { //FIND DUBLICATE
					$CI->session->set_flashdata('notice_message', get_phrase('Email_already_exists'));
					redirect($_SERVER['HTTP_REFERER'], 'refresh');
				} else { //NOT FIND
					return true;
				}
			}

		} else { //INVALID EMAIL
			$CI->session->set_flashdata('error_message', get_phrase('Invalid_email'));
			redirect($_SERVER['HTTP_REFERER'], 'refresh');
		}
		

	}
Comment

PREVIOUS NEXT
Code Example
Php :: add selected to dropdpown item laravel 
Php :: php version 7.4 
Php :: validate unique or equal 
Php :: wp+ theme translate 
Php :: laravel upsert always inserting 
Php :: woocommerce show percentage in sales badge 
Php :: PHP Forms - Validate E-mail and URL 
Php :: change regards line laravel 
Php :: php file structure 
Php :: add object to http request php behamin proxy bproxy 
Php :: contact us page mail prestashop 
Php :: registration form in php and mysql 
Php :: php spellchecker 
Php :: how to use db more than 1 codeigiter 3 
Php :: Laravel, return view with Request::old 
Php :: Code début HTML 
Php :: -inurl:(htm/html/php/pls/txt) intitle:index.of "last modified" (mp4/wma/aac/avi) 
Php :: TypeError: Argument 1 passed to DrupalCoreEntityEntityViewBuilder::view() must implement interface 
Php :: calculate age from date of birth php 
Php :: laravel belongsto nested 
Php :: Parameters inside Laravel localized string 
Php :: php check timeout 
Php :: pakistan standard time zone 
Php :: How to create an Invoice with watermark FPDF 
Php :: diferencias empty() e isset() 
Php :: laravel mix build as umd 
Php :: php isset tableau 
Php :: yii2 multilple andFilterWhere 
Php :: php usort two columns 
Php :: handling deadlocks laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =