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 ...";
}
?>
The IE or FF detector
Hello Friends,Problem of today ( we seek for php help ) as following ,we know all that PNG images not shown well on IE6 and some "css'ers" given us a solution --> fine 1but if that
SAP Treasury - Commodities
We are running SAP ECC 6.0 with Treasury Activated.
losing variables between php brackets
Hihave got this code:Code:
Tournament Brackets (Double Elimination)?
Is making a double elimination tournament style bracket system capable of being done in php?After dealing with numerous very well qualified programmers to only turn down the project due to difficulty
Help Import Animoto and Youtube
CAn someone help me urgently want to allow users on my website to import youtube/revver/dailymotion and very important animoto videos into the site.This feature will come in the upload window.Can this
error checking breaking my code
Hi there, OK first of all, big apologies for what I assume is really fundamental errors in the structure of my code. I'm really new at this and still learning, but I'm almost at the stage of giving up
* Gridview and Detailsview in UpdatePanel, insert mode problem
I have a GridView and DetailsView working together. When a record from Gridview is selected, DetailsView is opened for edit/insert/deletion of records. When user searches for a record and no record
Handling text changed in text box control using Ajax
I need to create a web form with a text box control. When someone types text into the textbox I need to post back to a C# or VB method to handle the changed text entered into the text box control.Is
Login logout link help
Hi all,Im new to php and Im having trouble creating a login/logout link for my page that displays as: Log Out | My Account.when a member is signed in, And: Log In | Sign UpWhen no one is signed in.The
need help in update query
i create a form for update. there are 8 columns in my mysql table. on my main page all the data is retrieve from db and displayed on the page. after every row there is a link edit. when user click