this is my validation for my form but there is something wrong with it
if ($_POST['submit'])
{
$user="";
$host="";
$password="";
$database="";
$connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
$db=mysql_select_db($database,$connection);
$errCount = 0;
$fineCount = 0;
$errMessage = "";
$required_fields=array('name','email','contact_address','mobile','workhome_tel','contact_postcode','project_postcode','designstyle','programtimecompletion','budgetcost','feeconstraint','projectdeadline','reason2build');
$field_errors=array('your name please','your email address','your contact address','your mobile phone number','your work or home tel. number','what is your contact postcode','what is the project postcode','your style of design','time estimated to complete program','your budget for project','your fee constraint','importance of project deadline','your reason to build');
for($i=0;$i<count($required_fields);$i++) {
if(!isset($_POST[$required_fields[$i]]) || $_POST[$required_fields[$i]]=='') {
$err[$errCount]='You must provide a '.$_POST[$required_fields[$i]];
$errCount = $errCount + 1;
$errMessage = "$errMessage $_POST[$required_fields[$i]]";
}else{
$field[$fineCount] = $_POST[$required_fields[$i]];
$fineCount = $fineCount + 1;
}
}
if (count($err)>0) {
//output error code
$strOut = "Your submision generated the following errors:<br>";
$errors = preg_split('/ /', $errMessage, -1);
foreach($errors as $e) {
echo $field_errors[$e] . "<br>";
}
}else{ //start sql query
i get an error at this line
$errMessage = "$errMessage $_POST[$required_fields[$i]]";
and i am not sure what to do about it.