The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 871 - File: showthread.php PHP 7.4.30 (Linux)
File Line Function
/showthread.php 871 errorHandler->error


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
Problem w/server-side validation
I want to make some fields required and validate the e-mail address. After implimenting the code as described in the documentation area, I am receiving an error "inside" the form field before I even submit anything.

Here is my form code:

PHP Code:
$fields ft_api_init_form_page(2);

// validation time!
$errors = array();
if (isset(
$rules = array();
$rules[] = "required,name,Please enter your name.";
$rules[] = "required,city,Please enter your city.";
$rules[] = "required,email,Please enter your email address.";
$rules[] = "valid_email,email,Please enter a valid email address.";
$rules[] = "required,address,Please enter your address.";
$errors validate_fields($_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_application",
"next_page" => "thankyou.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true
// it failed validation. Update $fields with the latest contents of the form data
$fields array_merge($_SESSION["form_tools_form"], $_POST);

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <link rel="stylesheet" type="text/css" href="global/styles.css">
<body background="images/bkg.jpg">
// 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))
"<div class='error'>Please fix the following errors:\n<ul>";
  foreach (
$errors as $error)

<div id="container">
<table id="Table_01" border="0" cellpadding="0" cellspacing="0">
        <td colspan="3">
            <img src="images/application_01.jpg" width="965" height="141" alt=""></td>
        <td width="61" valign="top" background="images/application_02.jpg">
            <img src="images/application_02.jpg" width="61" height="478" alt=""></td>
      <td width="839" align="left" valign="top" background="images/application_03.jpg">
      <div id="innercontainer">
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
          <table width="818" border="0" cellspacing="0" cellpadding="8" background="images/application_03.jpg">
              <td colspan="3"><h1>PERSONAL INFORMATION</h1></td>
              <td width="5">&nbsp;</td>
              <td width="453">Name</td>
              <td width="312"><input type="text" name="name" id="name" value="<?=htmlspecialchars($fields["name"])?>"></td>
              <td><input type="text" name="address" id="address" value="<?=htmlspecialchars($fields["address"])?>"></td>
              <td><input type="text" name="city" id="city" value="<?=htmlspecialchars($fields["city"])?>"></td>
              <td><input type="text" name="state" id="state"></td>
              <td><input type="text" name="zipcode" id="zipcode"></td>
              <td>Phone Number (must be numbers only, include area code)</td>
              <td><input type="text" name="phone" id="phone"></td>
              <td>E-Mail Address</td>
              <td><input type="text" name="email" id="email" value="<?=htmlspecialchars($fields["email"])?>"></td>

The error I'm getting when I goto this form to start filling it out is:
(this is the name field)
<br /><b>Notice</b>:  Undefined index:  name in <b>D:\Hosting\4885718\html\application\application.php</b> on line <b>80</b><br />

Line 80 in my form reads:
<td width="312"><input type="text" name="name" id="name" value="<?=htmlspecialchars($fields["name"])?>"></td>

Any help you can offer would be greatly appreciated.

Messages In This Thread
Problem w/server-side validation - by aalsmo - Dec 5th, 2009, 8:36 PM
RE: Problem w/server-side validation - by Ben - Dec 6th, 2009, 9:40 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)