Please help me with this code. I Don't know how to over come this error?

Form Application

Web Developer Required

Please fill in the following form to apply for this job

Name:
Phone:
Email:
Address:
Gender: Male:Female:
City Islamabad Lahore Islamabad Talagang Karachi Peshawar Quetta
Age:
Skills[]: PHP :
HTML :
PHOTOSHOP :
JAVASCRIPT :
AJAX :
MYSQL :
 

Second File

<?php // clean white spaces and special characters from values function cleanStr($str) { $cStr = trim($str); $cStr = htmlspecialchars($cStr); $cStr = addslashes($cStr); return $cStr; } // check for empty values function emptyFields($ar) { if(!is_array($ar)) { print "The argument must be an array"; return false; } //loop through each field and check for empty foreach($ar as $key => $value){ $value = cleanStr($value); if(empty($value)){ print "".ucwords($key). " must not be empty. Please Click the browser back button and correct it."; return false; } } return true; } // calling function to check any empty value if(!emptyFields($_POST)) { exit(); } // check required skills and age function isEligible($skills, $age){ $age = intval($age); if(count($skills)==0){ print("You dont have any skill"); return false; } if($age<23||$age>35){ print("Your age must be between 23 and 35"); return false; } return true; } //assigning fields values to variables $name = cleanStr($_POST['name']); $phone = cleanStr($_POST['phone']); $email = cleanStr($_POST['email']); $address = cleanStr($_POST['address']); $gender = cleanStr($_POST['gender']); $city = cleanStr($_POST['city']); $age = (int)cleanStr($_POST['age']); $skills = $_POST['skills']; //calling function to check //that the candidate is eligiable for applying to this job if(!isEligiable($skills,age)){ exit(); } //if every thing is ok print "

Thank you".$name. "for your interest in this job. We will contact you soon.

"; print "We received the following information about you.
"; //print user submited information print "Name: ". $name. "
"; print "Phone: ". $phone. "
"; print "Email: ". $email. "
"; print "Address: ". $address. "
"; print "Gender: ". $gender. "
"; print "City: ". $city. "
"; print "Age: ". $age. "
"; print "Your Skills: "; foreach($skills as $value){ print $value . ","; } ?>

and the error is

Warning: trim() expects parameter 1 to be string, array given in C:\xampp\htdocs\form\application.php on line 4
Skills must not be empty. Please Click the browser back button and correct it.

Hi,

When you submit the form it first check that Post variable is empty or not? correct. but in your POST variable there is one array name Skill[], trim function must except string not array.

Thank you my friend for your time.

Sponsor our Newsletter | Privacy Policy | Terms of Service