how to validate email id is already register or not function lawyer_register_form_submit($form,&amp;$form_state) 
{
$mail = $form_state['values']['mail'];
$new_password = user_password();
$edit = array(
  'name' =&gt; $form_state['values']['name'],
  'pass' =&gt; $new_password,
  'mail' =&gt; $mail,
  'init' =&gt; $mail,
  'status' =&gt; 1,
  'access' =&gt; REQUEST_TIME,
  );
  if(!db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail;", array(':mail' =&gt;  $mail))-&gt;fetchField())
  {
  $to = $form_state['values']['mail'];
  $subject = 'Lawandmoney New account created';
  $headers = "From: admin@lawandmoney.info\nContent-type: text/html";
  $body = 'A new user account has been created for you at &lt;a  href="http://us.lawandmoney.info"&gt;us.lawandmoney.info&lt;/a&gt;.&lt;br /&gt; Your login details are as  follows:&lt;br /&gt;Username: &lt;b&gt;'.$form_state['values']['name'].'&lt;/b&gt;&lt;br /&gt; Password:  &lt;b&gt;'.$new_password.'&lt;/b&gt; &lt;br /&gt;&lt;br /&gt; Please login to &lt;a  href="http://us.lawandmoney.info"&gt;us.lawandmoney.org&lt;/a&gt; and change your password.&lt;br /&gt;';
     user_save(drupal_anonymous_user(), $edit);
     if($form_state['values']['send_message'] == 1)
     {
     mail($to,$subject,$body,$headers);
     drupal_set_message("Sussessful register.Please check your Email for login   deatils."); 
     }
     else 
     {  
     drupal_set_message("mail not send.");
     }
     }
     else 
     {
     drupal_set_message("You are already register.");
     }


we created a custom user registration form.now we have to checked if user is already register then its give error like You are already register, data will not inserted into database and mail not send to user.
This can be done with hook_form_alter:

function module_(&amp;$form, &amp;$form_state, $form_id) {
  $user_login_forms = array('user_login', 'user_login_block');
  if (in_array($form_id, $user_login_forms)) {
    $form['#validate'][] = 'my_validate_function';
  }
}

function my_validate_function(&amp;$form, &amp;$form_state) {
  $name = $form_state['values']['name'];
  // Drupal 6:
  if (!db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s';", $name))) {
    // User doesn't exist
  }
  // Drupal 7:
  if (!db_query("SELECT COUNT(*) FROM {users} WHERE name = :name;", array(':name' =&gt; $name))-&gt;fetchField()) {
    // User doesn't exist
   }
}


It's better to query the DB directly in this case than than using user_load as it hooks into other modules as well.