--- C:/DOCUME~1/pieter/LOCALS~1/Temp/fbconnect.pages.inc-revBASE.svn000.tmp.inc	Tue Aug  2 15:56:53 2011
+++ T:/coracle/www/sites/all/modules/vendor/fbconnect/fbconnect.pages.inc	Tue Aug  2 15:54:08 2011
@@ -90,6 +90,13 @@
      //user allready registered facebook account to site, log them in
      $form_state['uid'] = $user_id;     
      user_login_submit($form, $form_state);
+  }else{      
+    if( email_allready_exist( $data['email'] ) ){
+        //the user was not found in the fbconnect_users table, but the emial from facebook might allready have an account on coracle.
+        //Redirect user to the login page with a message.
+        drupal_set_message('This email address is allready registered to an account. Please log in to continue');
+        drupal_goto('user/login');
+    }
   }
   
   $form  = drupal_retrieve_form('user_register_form', $form_state);
@@ -174,6 +181,17 @@
 
   return $form;
 }
+/**
+* Check the users table to see if the email is allready in the drupal system
+* 
+*/
+function email_allready_exist($email){
+    $query = db_select('users', 'u');
+    $query->fields('u',array('uid'));
+    $query->condition('mail', $email, '=');
+    return $query->execute()->fetchField();
+}
+
 function facebook_login_page(&$form, $form_state = array()){
     $facebook = facebook_client();
     $login_url = $facebook->getLoginUrl();
