I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the trick when trying to check to see if the array is empty. Is my understanding of empty()incorrect? Each item is the array is either a string, the error message, or FALSE.
Can anyone help me figure out how to move into my if statement?
Code: <?php
// check fields
$errors = array();
$errors['the_date'] = (empty($the_date)) ? '<span class="error">Please choose a date.</span>' : FALSE;
$errors['first_name'] = (empty($first_name)) ? '<span class="error">Please fill in your first name.</span>' : FALSE;
$errors['last_name'] = (empty($last_name)) ? '<span class="error">Please fill in your last name.</span>' : FALSE;
$errors['email'] = (empty($email) || !preg_match("/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*(([,]|[,])s*w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*)*$/", $email)) ? '<span class="error">Please fill in a valid email address.</span>' : FALSE;
$errors['phone'] = (empty($phone)) ? '<span class="error">Please provide your phone number.</span>' : FALSE;
$errors['emergency_contact'] = (empty($emergency_contact)) ? '<span class="error">Please provide an emergency contact.</span>' : FALSE;
$errors['emergency_phone'] = (empty($emergency_phone)) ? '<span class="error">Please provide an emergency phone number.</span>' : FALSE;
$errors['major_interest'] = (empty($major_interest)) ? '<span class="error">Please pick a major of interest.</span>' : FALSE;
$errors['activity1'] = (empty($activity1)) ? '<span class="error">Please select a morning activity.</span>' : FALSE;
$errors['activity2'] = (empty($activity2)) ? '<span class="error">Please select a morning activity.</span>' : FALSE;
$errors['activity3'] = (empty($activity3)) ? '<span class="error">Please select an afternoon activity.</span>' : FALSE;
$errors['activity4'] = (empty($activity4)) ? '<span class="error">Please select an afternoon activity.</span>' : FALSE;
$errors['interests'] = (empty($interests)) ? '<span class="error">Please list your interests.</span>' : FALSE;
$errors['accomodations'] = (empty($accomodations)) ? '<span class="error">Please answer.</span>' : FALSE;
$errors['acknowledgement'] = (!(strcmp($acknowledgement, 'I understand') == 0)) ? '<span class="error">Please type the indicated response.</span>' : FALSE;
// does the email exist? did they already register?
$errors['checkEmail'] = checkEmail($email);
//print_r($errors);
if (empty($errors))
{
header('Location: thankyou.php');
exit();
//$sql = "INSERT INTO ...";
}
?>
modifying a property of an object from a different class
I have 2 classes:- Math- Distancein my math class, I have this line:$distance = new Distance($this->query, $this->distances);and this property:public $special = array();in my Distance
JQuery, Masterpage, and Control issue
Hey everyone, I am using JQuery in several sites so I thought it would be best to place the library reference in the masterpage. It works great everywhere, except when my javascrip is called from
Where am I going wrong
Been trying to work this out for hours I have two tables called 'Genres' and 'Films'. Genres contains two columns 'Genre_id' and 'Genre_Name'. Films contains a load of columns, the most important
login form can you find my error?
registrationform.php seems fine send data to registration.phpregistration.php seems fine checks all data then send it to function.phpconnection.php does its job and connects to database also calls
CURL question
i am wondering if it's possible to use multi curl with login something likelogin once to website and after that use multi curl to download several pagesthank you
FTP issues
Hi all,I am currently facing some serious problems with a script and really need some advise before I am actually sick To give you a brief overview of the situation, I have a script which is going to
Mysql error message
help me find out what this error message means:"Duplicate entry '0' for key 'PRIMARY'"the sql for it is Code: INSERT INTO accounts (firstname, lastname, username, password, joined, email,
temporary objects
Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compiler (gcc) is reporting an error on line k.f();, but not g().f(); and g() = k;. Does anyone
Help with lottery style system?
I'm working on a currency system for forums and it is going to have a type of lottery system built into it. Trying to figure out the best way to make the drawings work. I'm still new to cron jobs but
displaying email without attracting a ton of spam
Hello,this is maybe the wrong place to ask.How would you display an email address on a website without attraciting all the spammers of the world to fill your mailbox ?does anybody use something