function validateFormData($isNewRegistration = true)
 {
     // isNewRegistration true= sign uppage | false= settings page
     $fdata->result = true;
     $fdata->alert = '';
     // the stuff we get from facebook or user but might be invalid anyway
     $fdata->name = stripslashes($_POST['name']);
     $fdata->email = stripslashes($_POST['email']);
     $fdata->gender = stripslashes($_POST['gender']);
     $fdata->age = stripslashes($_POST['age']);
     $fdata->city = stripslashes($_POST['city']);
     $fdata->state = stripslashes($_POST['state']);
     $fdata->country = stripslashes($_POST['country']);
     if (isset($_POST['zip'])) {
         $fdata->zip = stripslashes($_POST['zip']);
     } else {
         $fdata->zip = '';
     }
     /*$fdata->researchImportance=	$_POST['researchImportance'];  // tentatively moved into templates since this field may be site-specific
     		if ($isNewRegistration OR $fdata->researchImportance==0)
     			$fdata->showResearchImportance=true;*/
     $fdata->optInStudy = stripslashes($_POST['optInStudy']) == 'on' ? 1 : 0;
     $fdata->acceptRules = stripslashes($_POST['acceptRules']) == 'on' ? 1 : 0;
     $fdata->noCommentNotify = stripslashes($_POST['noCommentNotify']) == 'on' ? 1 : 0;
     $fdata->rxFeatures = stripslashes($_POST['rxFeatures']) == 'on' ? 1 : 0;
     $fdata->rxMode = stripslashes($_POST['rxMode']);
     // TODO:optInEmail, etc
     // stuff we get from facebook that cant be invalid
     $fdata->proxied_email = $this->session->proxied_email;
     if ($fdata->name == '') {
         $fdata->alert .= 'Somehow you are using facebook without a name. ' . 'You rebel you. But we still need one.<br />';
         $fdata->result = false;
     }
     if ($this->accountTemplate->collectEmail) {
         if (!$this->validEmail($fdata->email)) {
             //$fdata->alert .= 'In order to earn points and redeem '.
             //'rewards as part of the '.SITE_TEAM_TITLE.' we do need your email address.<br />';
             $fdata->alert .= 'In order to participate in the ' . SITE_TEAM_TITLE . ' we do need your email address.<br />';
             $fdata->result = false;
         } else {
             // check if email exists
             if ($isNewRegistration) {
                 require_once PATH_CORE . '/classes/user.class.php';
                 $userTable = new UserTable($this->db);
                 if ($userTable->checkEmailExist($fdata->email)) {
                     $fdata->alert .= 'This email address is already registered with us. <br />' . ($fdata->result = false);
                 }
             }
         }
     }
     if ($this->accountTemplate->collectAge) {
         if ($fdata->age == '' || !is_numeric($fdata->age)) {
             $fdata->alert .= 'Sorry, the age you entered is invalid.<br />';
             $fdata->result = false;
         }
         if ($fdata->age < 16) {
             $fdata->alert .= 'Sorry, we cannot accept people under 16 years of age.<br />';
             $fdata->result = false;
         }
     }
     if ($this->accountTemplate->collectLocation) {
         if ($fdata->city == '' || $fdata->state == '' || $fdata->country == '') {
             $fdata->alert .= 'We need to know your city, state, and country of residence.<br />';
             $fdata->result = false;
         }
     }
     if ($isNewRegistration and !$fdata->acceptRules) {
         $fdata->alert .= "You must accept the rules to sign up!<br />";
         $fdata->result = false;
     }
     // extra checks and fields we might want to retrieve, especially the research fields
     $fdata = $this->accountTemplate->validateFormData($fdata);
     return $fdata;
 }