September 13, 200718 yr Im trying to validate a web form field so that the same username doesnt get used by more than one customer. The relevant code follows: <?php include_once('FX/FX.php'); include_once('FX/server_data.php'); $whopays_1 = $_POST['payers']; $ACWAMember_1 = $_POST['ACWAMember']; $ACWAMemberNumber_1 = $_POST['ACWAMembershipNumber']; $CCWTMember_1 = $_POST['CCWTVIP']; $CCWTMemberNumber_1 = $_POST['CCWTMembershipNumber']; $firstname_1 = $_POST['firstname1']; $lastname_1 = $_POST['lastname1']; $gender_1 = $_POST['gender1']; $jobtitle_1 = $_POST['jobtitle1']; $employer_1 = $_POST['employer1']; $program_1 = $_POST['program1']; $which_address_1 = $_POST['whichaddress1']; $workaddressline1_1 = $_POST['workaddressline1_1']; $workaddressline2_1 = $_POST['workaddressline2_1']; $worksuburbtown_1 = $_POST['worksuburbtown1']; $workstate_1 = $_POST['workstate1']; $workpostcode_1 = $_POST['workpostcode1']; $workphoneareacode_1 = $_POST['workphoneareacode1']; $workphone_1 = $_POST['workphone1']; $workfaxareacode_1 = $_POST['workfaxareacode1']; $workfax_1 = $_POST['workfax1']; $workemail_1 = $_POST['workemail1']; $mobile1_1 = $_POST['mobile1_1']; $ATSI_1 = $_POST['ATSI1']; $CALD_1 = $_POST['CALD1']; $clients_1 = $_POST['clients1']; $otherclients_1 = $_POST['otherclients1']; $servicetype_1 = $_POST['servicetype1']; $otherservicetype_1 = $_POST['otherservicetype1']; $mailouts_1 = $_POST['mailouts1']; $howfindout_1 = $_POST['howfindout1']; $conditions_1 = $_POST['conditions1']; $homeaddressline1_1 = $_POST['homeaddressline1_1']; $homeaddressline2_1 = $_POST['homeaddressline2_1']; $homesuburbtown_1 = $_POST['homesuburbtown1']; $homestate_1 = $_POST['homestate1']; $homepostcode_1 = $_POST['homepostcode1']; $homephoneareacode_1 = $_POST['homephoneareacode1']; $homephone_1 = $_POST['homephone1']; $homefaxareacode_1 = $_POST['homefaxareacode1']; $homefax_1 = $_POST['homefax1']; $homeemail_1 = $_POST['homeemail1']; $mobile2_1 = $_POST['mobile2_1']; $username_1 = $_POST['username1']; $password_1 = $_POST['password1']; $confirmpassword_1 = $_POST['confirmpassword1']; $securityquestion_1 = $_POST['securityquestions']; $securityquestionanswer_1 = $_POST['securityquestionanswer']; $trainingaccountid_1 = date("ymdHis"); $creationdate_1 = date ("d/m/Y"); $remoteaddr = $_SERVER['REMOTE_ADDR']; $errors=array(); ***Lots of other field validation is here*** ***Problem code starts here*** $Username_Search=new FX($serverIP,$webCompanionPort,'FMPro7'); $Username_Search->SetDBData('Training_Account_Information.fp7','Training_Account_Information',$groupSize); $Username_Search->SetDBPassword('fmsadmin','fmsadmin'); $Username_Search->AddDBParam('User_Name',$username_1, 'eq'); $Username_Search->FMSkipRecords($skipSize); $Username_SearchResult=$Username_Search->FMFind(); $returnedCount=$Username_SearchResult['foundCount']; foreach($Username_SearchResult['data'] as $key=>$Username_SearchData); if( $returnedCount != 0 ) {$errors['username1']= 'This username has already been taken. Please choose a different username.';} ***Problem code ends here*** if(strlen($username_1) > 12) {$errors['username1']= 'The username must be no longer than 12 characters. Please edit this information.';} if(strlen($username_1) < 6) {$errors['username1']= 'The username must be at least 6 characters. Please edit this information.';} if(preg_match('/^[a-zA-Z0-9' ]+$/', $username_1) != 1) {$errors['username1']= 'The username may only contain text and numbers. Please edit this information.';} if(empty($username_1)) {$errors['username1']= 'Please enter a username.';} if(strlen($password_1) > 12) {$errors['password1']= 'The password must be no longer than 12 characters. Please edit this information.';} if(strlen($password_1) < 6) {$errors['password1']= 'The password must be at least 6 characters. Please edit this information.';} if(preg_match('/^[a-zA-Z'-' ]+$/', $password_1) != 1) {$errors['password1']= 'The password may only contain text and numbers. Please edit this information.';} if(empty($password_1)) {$errors['password1']= 'Please enter a password.';} if($confirmpassword_1 != $password_1) {$errors['confirmpassword1']= 'Your confirmation password does not match your password. Please reconfirm your password.';} if(empty($confirmpassword_1)) {$errors['confirmpassword1']= 'Please confirm your password.';} if(empty($securityquestion_1)) {$errors['securityquestions']= 'Please choose a security question.';} if(strlen($securityquestionanswer_1) > 50) {$errors['securityquestionanswer']= 'The answer to the security question is too long. Please edit this information.';} if(empty($securityquestionanswer_1)) {$errors['securityquestionanswer']= 'Please answer the security question.';} if (!empty($errors)){ include 'create_account.php'; exit(); } ?> ***HTML is here***
Create an account or sign in to comment