The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error with validateFields()
I'm getting an error which I've tried for hours to fix. My form is set up and functioning perfectly in FormTools 2. When I proceed to add PHP error checking I get the following error on submit:

Fatal error: Call to undefined function validateFields() in /home/idwebnet/public_html/bjwsa/employment/application.html on line 50

Here's the code at the top of my page:
$fields = ft_api_init_form_page(1);

$errors = array();
if (isset($_POST['submit']))
$rules = array();
$rules[] = "required,position,The Position You Are Applying For is required.";
$rules[] = "required,firstName,Your First Name is required.";
$rules[] = "required,lastName,Your Last Name is required.";
$rules[] = "required,presentAddressStreet,Present Street Address is required.";
$rules[] = "required,presentAddressCity,Present City is required.";
$rules[] = "required,presentAddressState,Present State is required.";
$rules[] = "required,presentAddressZip,Present Zip Code is required.";
$rules[] = "required,mainPhone,Your Main Phone Number is required.";
$rules[] = "valid_email,email,Please enter a valid email address.";
$rules[] = "required,highSchoolName,High School Name is required.";
$rules[] = "required,highSchoolLocation,High School Location is required.";
$rules[] = "required,highSchoolGradeCompleted,High School Last Grade Completed is required.";
$rules[] = "required,priorAppEmploy,Prior Employment with BJWSA is required.";
$rules[] = "required,relatives,Do any of your relatives work here? is required.";
$rules[] = "required,contactEmployer,May we contact your present or former employer? is required.";
$rules[] = "required,felony,Have you ever been convicted of a felony? is required.";
$rules[] = "required,immigrationStatus,Employment documentation is required.";
$rules[] = "required,shift,What shifts are you available to work? is required.";
$rules[] = "required,salaryRangeLow,What is your desired salary range - low? is required.";
$rules[] = "required,salaryRangeHigh,What is your desired salary range - high? is required.";
$rules[] = "required,employer1,Employer Name is required.";
$rules[] = "required,employerAddressStreet1,Employer Street Address is required.";
$rules[] = "required,employerAddressCity1,Employer City is required.";
$rules[] = "required,employerAddressState1,Employer State is required.";
$rules[] = "required,employerAddressZip1,Employer Zip is required.";
$rules[] = "required,employerTelephone1,Employer Telephone is required.";
$rules[] = "required,month18,Dates Employed Month From is required.";
$rules[] = "required,year18,Dates Employed Year From is required.";
$rules[] = "required,month19,Dates Employed Month To is required.";
$rules[] = "required,year19,Dates Employed Year To is required.";
$rules[] = "required,employerJobTitle1,Job Title is required.";
$rules[] = "required,employerStartingSalary1,Starting Salary is required.";
$rules[] = "required,employerEndingSalary1,Ending Salary is required.";
$rules[] = "required,employerSupervisor1,Supervisor Name is required.";
$rules[] = "required,employerLeaving1,Reason For Leaving is required.";
$rules[] = "required,referenceName1,Reference 1 is required.";
$rules[] = "required,referenceName2,Reference 2 is required.";
$rules[] = "required,referenceName3,Reference 3 is required.";
$rules[] = "required,jobOpeningReferral,How Were You Referred? is required.";
$rules[] = "required,sigName,Your Digital Signature is required (bottom of form).";

$errors = validateFields($_POST, $rules);

// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
$params = array(
"submit_button" => "submit",
"next_page" => "thank-you-employment.html",
"form_data" => $_POST,
"finalize" => true

And here's the code before the start of my form:
// if $errors is not empty, the form must have failed one or more validation
// tests. Loop through each and display them on the page for the user
if (!empty($errors))
echo "<div class='error'>Please fix the following errors:\n<ul>";
foreach ($errors as $error)
echo "<li>$error</li>\n";

echo "</ul></div>";

Here's the page under development:

My .htaccess file is set up to parse .HTML as PHP and like I said the form setup worked just great. The snag is the validation. I had it working fine in Form Tools 1.

By the way, the donation link on your site took me to a PayPal Sandbox. Is this a problem on my end since I have a PayPal sandbox account?

Thanks for the help! This script is GREAT!!
I had this problem until I discovered that the function in validate.php is actually validate_fields() and NOT validateFields() as given in all the online examples.
Many many thanks!! validate_fields() worked perfectly. I never thought to try that although I think I tried everything else. I appreciate your help!
Blurgh! Thanks for the tip - cssmw. I'll review the docs now and update it.

- Ben

Forum Jump:

Users browsing this thread: 1 Guest(s)