diff --git a/pcp.module b/pcp.module
index bc436f7..c999eae 100755
--- a/pcp.module
+++ b/pcp.module
@@ -3,7 +3,7 @@
 /**
  * @file
  * Allows users with valid permissions to tag profile fields created
- * from the profile module as required fields for a 
+ * from the profile module as required fields for a
  * users profile to be considered complete.
  */
 
@@ -21,7 +21,7 @@ function pcp_perm() {
  */
 function pcp_menu() {
   $items = array();
-  
+
   $items['admin/user/pcp'] = array(
     'title' => 'Profile Complete Percentages',
     'description' => 'Tag profile fields as required for percent complete handling.',
@@ -59,7 +59,7 @@ function pcp_block($op = 'list', $delta = 0, $edit = array()) {
               $content = theme('pcp_profile_percent_complete', $complete_data);
             }
             $block['subject'] = $subject;
-            $block['content'] = $content; 
+            $block['content'] = $content;
           }
           break;
       }
@@ -102,11 +102,11 @@ function pcp_form_profile_field_form_alter(&$form, $form_state) {
  * Implementation of hook_form_FORM_ID_alter().
  */
 function pcp_form_user_profile_form_alter(&$form, $form_state) {
-  if ($_GET['fieldname'] != '') {
+  if (isset($_GET['fieldname']) && $_GET['fieldname'] != '') {
     $fieldname = 'edit-'. preg_replace("/_/", "-", $_GET['fieldname']);
     drupal_add_js("
       $('#". $fieldname ."').css({
-        'border' : '2px solid red' 
+        'border' : '2px solid red'
         });
     ", 'inline', 'footer');
   }
@@ -120,7 +120,7 @@ function pcp_form_profile_field_delete_alter(&$form, $form_state) {
 }
 
 /**
- * Called when a user submits a profile field form from the 
+ * Called when a user submits a profile field form from the
  * profile module (when adding or editing a profile field).
  */
 function pcp_profile_field_form_submit($form, &$form_state) {
@@ -149,7 +149,7 @@ function pcp_user_admin_settings_submit($form, &$form_state) {
 /**
  * Menu Callback Function
  *  Build output of the pcp module settings which allows the
- *  administrator to tag specific profile fields which will be 
+ *  administrator to tag specific profile fields which will be
  *  used to determine the completion of a users profile.
  */
 function pcp_admin_settings() {
@@ -176,7 +176,7 @@ function pcp_admin_settings_form() {
     '#title' => 'Profile Fields',
     '#description' => t('Checking a profile field below will add that field to the logic of the complete percentage.'),
   );
-  
+
   // Add user picture support
   if (variable_get('user_pictures', 0)) {
     $form['profile_field_settings']['pcp_enable_user_picture'] = array(
@@ -186,7 +186,7 @@ function pcp_admin_settings_form() {
       '#description' => t('Picture support has been turned on, do you want to make it required as part of Profile Complete Percent? Checking this box will make it required.'),
     );
   }
-  
+
   $options = pcp_admin_settings_form_data();
   if ($options['profile_fields_options']) {
     $form['profile_field_settings']['profile_fields'] = array(
@@ -196,17 +196,17 @@ function pcp_admin_settings_form() {
       '#default_value' => $options['default_values'],
     );
   }
-  
+
   // Add user terms support
   if (module_exists('user_terms')) {
     $vocabs = taxonomy_get_vocabularies();
     $vocabs_enabled = variable_get('user_terms_vocabs', array());
     $all_vocabs = array();
-    
+
     foreach ($vocabs_enabled as $vid) {
       $all_vocabs[$vid] = $vocabs[$vid]->name;
     }
-    
+
     if (!empty($vocabs_enabled)) {
       $form['profile_field_settings']['pcp_enabled_user_terms_vocabs'] = array(
         '#title' => t('User Terms Vocabularies'),
@@ -216,7 +216,7 @@ function pcp_admin_settings_form() {
       );
     }
   }
-  
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
@@ -232,7 +232,7 @@ function pcp_admin_settings_form_submit($form, &$form_state) {
   variable_set('pcp_hide_block_on_complete', $form_state['values']['hide_block_on_complete']);
   variable_set('pcp_enable_user_picture', $form_state['values']['pcp_enable_user_picture']);
   variable_set('pcp_enabled_user_terms_vocabs', $form_state['values']['pcp_enabled_user_terms_vocabs']);
-  
+
   // Process the profile fields that have been modified if available.
   if (is_array($form_state['values']['profile_fields']) && !empty($form_state['values']['profile_fields'])) {
     db_query("DELETE FROM {profile_pcp}");
@@ -246,12 +246,12 @@ function pcp_admin_settings_form_submit($form, &$form_state) {
 }
 
 /**
- * Function that sets up parameters to be used 
+ * Function that sets up parameters to be used
  * when the pcp_admin_settings_form() function
- * is executed. 
+ * is executed.
  *
  * @return - assoc array
- *  ['profile_fields_options'] 
+ *  ['profile_fields_options']
  *    - An associative array of all fields created from the profile module.
  *  ['default_values']
  *    - An indexed array of all (if any) default values for the form.
@@ -267,7 +267,7 @@ function pcp_admin_settings_form_data() {
   foreach ($tagged_profile_fields as $key => $value) {
     $default_values[] = $value['fid'];
   }
-  
+
   $options = array();
   $options['profile_fields_options'] = $field_options;
   $options['default_values'] = $default_values;
@@ -312,20 +312,20 @@ function pcp_get_user_additional_values($uid) {
 
       foreach ($account->user_terms AS $term) {
         $vid = $term['vid'];
-        $values['user_terms_' . $vid][] = $term;        
+        $values['user_terms_' . $vid][] = $term;
       }
     }
   }
-  
+
   return $values;
 }
 
 /**
  * Get the profile complete percentage data for a given user.
  *
- * @param obj $user 
+ * @param obj $user
 *  - The user object to get data for.
- *  
+ *
  * @return assoc array of all values needed at the theme layer.
  *  - Refer to comments in theme_pcp_profile_percent_complete() for specific values.
  */
@@ -342,17 +342,17 @@ function pcp_get_complete_percentage_data($user) {
   $nextfield_set = FALSE;
 
   if (is_array($fields) && !empty($fields)) {
-    
+
     //Shuffle the fields to display a random field to fill in (issue #708382)
     shuffle($fields);
-    
+
     foreach ($fields as $key => $value) {
-      if (($user_values[$value['fid']] == '') || ($user_values[$value['fid']] == '0' && $value['type'] == 'selection')) {
+      if (isset($user_values[$value['fid']]) && (($user_values[$value['fid']] == '') || ($user_values[$value['fid']] == '0' && $value['type'] == 'selection'))) {
         if ($nextfield_set === FALSE) {
           $nextfield_set = TRUE;
           $fid = $value['fid'];
           $nextfield_fid = $fid;
-          
+
           if (is_numeric($fid)) {
             $nextdata = db_fetch_array(db_query("SELECT title, name, category FROM {profile_fields} WHERE fid = %d", $fid));
             $nextfield = $nextdata['title'];
@@ -381,7 +381,7 @@ function pcp_get_complete_percentage_data($user) {
       $nextpercent = $next * 100;
     }
   }
-  
+
   $complete_data = array();
   $complete_data['uid'] = $user->uid;
   $complete_data['percent'] = $percent;
@@ -393,7 +393,7 @@ function pcp_get_complete_percentage_data($user) {
   $complete_data['nextpercent'] = $nextpercent;
   $complete_data['nextcategory'] = $nextcategory;
   $complete_data['nextname'] = $nextname;
-  
+
   return $complete_data;
 }
 
@@ -407,14 +407,14 @@ function pcp_get_complete_percentage_data($user) {
  */
 function pcp_get_tagged_profile_fields($fid = 0) {
   $profile_role_used = module_exists('profile_role');
-  
+
   if ($fid > 0) {
     $query = db_query("SELECT * FROM {profile_pcp} LEFT JOIN {profile_fields} USING(fid) WHERE fid = %d", $fid);
   }
   else{
     $query = db_query("SELECT * FROM {profile_pcp} LEFT JOIN {profile_fields} USING(fid)");
   }
-  
+
   $fields = array();
   while ($result = db_fetch_array($query)) {
     if ($profile_role_used) {
@@ -427,7 +427,7 @@ function pcp_get_tagged_profile_fields($fid = 0) {
       $fields[] = $result;
     }
   }
-  
+
   return $fields;
 }
 
@@ -440,7 +440,7 @@ function pcp_get_profile_fields() {
   while ($result = db_fetch_array($query)) {
     $fields[] = $result;
   }
-  
+
   return $fields;
 }
 
@@ -451,7 +451,7 @@ function pcp_get_profile_fields() {
  */
 function pcp_get_additional_tagged_fields() {
   $fields = array();
-  
+
   // Enable user picture support.
   if (variable_get('pcp_enable_user_picture', 0) && variable_get('user_pictures', 0)) {
     $fields['user_picture'] = array(
@@ -460,13 +460,13 @@ function pcp_get_additional_tagged_fields() {
       'name' => 'picture_upload',
     );
   }
-  
+
   if (module_exists('user_terms')) {
     $vocabs             = taxonomy_get_vocabularies();
     $user_terms_vocabs  = variable_get('pcp_enabled_user_terms_vocabs', array());
     $vocabs_path        = variable_get('user_terms_vocabs_path', array());
     $all_vocabs         = array();
-    
+
     foreach ($user_terms_vocabs as $vid) {
       $all_vocabs[$vid] = $vocabs[$vid]->name;
     }
@@ -479,7 +479,7 @@ function pcp_get_additional_tagged_fields() {
       );
     }
   }
-  
+
   return $fields;
 }
 
@@ -503,7 +503,7 @@ function pcp_theme() {
  *  ['incomplete'] - int - How many fields still need to be filled out.
  *  ['total'] - int - The count of all tagged profile fields.
  *  ['nextfield'] - str - The next field to fill out that is currently empty.
- *  ['nextfield_fid'] - int or str - The fid identifier of the field being passed in. 
+ *  ['nextfield_fid'] - int or str - The fid identifier of the field being passed in.
  *  ['nextpercent'] - int - What the users total percent complete value will be when ['nextfield'] is complete.
  *  ['nextcategory] - str - The category the next field falls under for targeting with a link.
  *  ['nextname'] - str - The field name of the next field for field focus after linked to the profile field.
@@ -513,14 +513,14 @@ function theme_pcp_profile_percent_complete($complete_data) {
   $output .= '#pcp-percent-bar-wrapper {width: 100%; border: 1px solid #000; padding: 1px;}';
   $output .= '#pcp-percent-bar { width: '. $complete_data['percent'] .'%; height: 10px; background-color: #777777;}';
   $output .= '</style>';
-  
+
   $output .= '<div id="pcp-wrapper">';
   $output .= t('!complete% Complete', array('!complete' => $complete_data['percent']));
   $output .= '<div id="pcp-percent-bar-wrapper">';
   $output .= '<div id="pcp-percent-bar"></div>';
   $output .= '</div>';
   $output .= '</div>';
-  
+
   if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
 
     if ($complete_data['nextcategory'] == 'Default') {
@@ -529,17 +529,17 @@ function theme_pcp_profile_percent_complete($complete_data) {
     else {
       $nextpath = 'user/'. $complete_data['uid'] .'/edit/'. $complete_data['nextcategory'];
     }
-    
+
     $element_id = 'edit-' . str_replace('_', '-', $complete_data['nextname']);
     $output .= t('Filling out <em>!empty-field</em> will bring your profile to !complete% Complete', array('!empty-field' => l($complete_data['nextfield'], $nextpath, array('query' => 'fieldname='. $complete_data['nextname'], 'fragment' => $element_id)), '!complete' => $complete_data['nextpercent']));
   }
-    
+
   return $output;
 }
 
 /**
  * Implementation of hook_rules_condition_info().
- * 
+ *
  * @ingroup rules
  * @see content_complete_completeness_percentage_form
  */
@@ -558,7 +558,7 @@ function pcp_rules_condition_info() {
 
 /**
  * Rules Condition form configuration - select the profile fields to check
- * 
+ *
  * @see pcp_rules_condition_info
  */
 function pcp_condition_check_profile_fields_completeness_form($settings = array(), &$form) {
@@ -574,15 +574,15 @@ function pcp_condition_check_profile_fields_completeness_form($settings = array(
 
 /**
  * Rules Condition - Are the selected user profile fields filed in?
- * 
- * @param $user 
+ *
+ * @param $user
  *   The user for which the condition is checked.
  * @param $settings
  *   The configured settings of the rule condition
- * 
+ *
  * @see pcp_condition_check_profile_fields_completeness_form
  * @see pcp_rules_condition_info
- * 
+ *
  * @return TRUE or FALSE
  */
 function pcp_condition_check_profile_fields_completeness($user, $settings) {
@@ -592,10 +592,10 @@ function pcp_condition_check_profile_fields_completeness($user, $settings) {
     $result = db_query("SELECT fid, title, name, category FROM {profile_fields} WHERE fid IN (%d)", implode(', ', $settings['profile_fields']));
     while ($field = db_fetch_object($result)) {
       if (!$user->{$field->name}) {
-        return FALSE;    
+        return FALSE;
       }
     }
-  } 
+  }
   return TRUE;
 }
 
@@ -616,14 +616,14 @@ function pcp_rules_action_info() {
 
 /**
  * Rules Action - Redirect the user to his profile edit page
- * 
- * @param $user 
+ *
+ * @param $user
  *   The user for which the action is performed.
  * @param $settings
  *   The configured settings of the rule action
- * 
+ *
  * @see pcp_rules_action_info
- * 
+ *
  * @return Perform the redirection
  */
 function pcp_action_redirect_user_to_editform($user, $settings) {
@@ -642,7 +642,7 @@ function pcp_action_redirect_user_to_editform($user, $settings) {
         drupal_goto('user/' . $user->uid . '/edit/' . $field->category);
       }
     }
-  } 
+  }
 }
 
 
