473,813 Members | 3,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check if any fields are filled in

I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.

Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last_n ame !=='')

What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.

Nov 6 '07 #1
16 4167
On Nov 6, 4:50 pm, mtuller <mitul...@gmail .comwrote:
I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.

Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last_n ame !=='')

What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.
Replace && with ||

Nov 6 '07 #2
On Nov 6, 4:15 pm, Darko <darko.maksimo. ..@gmail.comwro te:
On Nov 6, 4:50 pm, mtuller <mitul...@gmail .comwrote:
I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.
Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last_n ame !=='')
What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.

Replace && with ||
Just expanding on Darko's answer - && means 'if condition 1 and
condition 2 are true'. || means 'if at least one condition is true'.
Both can be used with more than two conditions as well.

Nov 6 '07 #3
On Nov 6, 10:15 am, Darko <darko.maksimo. ..@gmail.comwro te:
On Nov 6, 4:50 pm, mtuller <mitul...@gmail .comwrote:
I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.
Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last_n ame !=='')
What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.

Replace && with ||
Sorry, the subject of this is wrong. I don't want to check if any
fields are empty. I want to check if all are empty. That's why I have
&&.

Nov 6 '07 #4
mtuller wrote:
On Nov 6, 10:15 am, Darko <darko.maksimo. ..@gmail.comwro te:
>On Nov 6, 4:50 pm, mtuller <mitul...@gmail .comwrote:
>>I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.
Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last _name !=='')
What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.
Replace && with ||

Sorry, the subject of this is wrong. I don't want to check if any
fields are empty. I want to check if all are empty. That's why I have
&&.
if (empty($nominee _first_name) && empty($nominee_ middle_initial) &&
empty($nominee_ last_name))

--
Posted via a free Usenet account from http://www.teranews.com

Nov 6 '07 #5
On Nov 6, 11:20 am, Justin Koivisto <justin.koivi.. .@gmail.comwrot e:
mtuller wrote:
On Nov 6, 10:15 am, Darko <darko.maksimo. ..@gmail.comwro te:
On Nov 6, 4:50 pm, mtuller <mitul...@gmail .comwrote:
>I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a
message will appear. I can't get the check to happen on multiple
fields though.
Here is what I have:
if ($nominee_first _name !=='' && $nominee_middle _initial !=='' &&
$nominee_last_ name !=='')
What happens is that if all fields have content, the page passes, and
all I care about is that there is something entered in at least one
field.
Replace && with ||
Sorry, the subject of this is wrong. I don't want to check if any
fields are empty. I want to check if all are empty. That's why I have
&&.

if (empty($nominee _first_name) && empty($nominee_ middle_initial) &&
empty($nominee_ last_name))

--
Posted via a free Usenet account fromhttp://www.teranews.co m
I had tried that too. Except I used !empty.

if (!empty($nomine e_first_name) && !empty($nominee _middle_initial ) && !
empty($nominee_ last_name))
{
// If not empty, insert into database
$nominee_field_ query = "INSERT INTO faculty_nominat ions.nomination s
(nominee_first_ name, nominee_middle_ initial, nominee_last_na me,
nominee_comment s)
values ('$nominee_firs t_name', '$nominee_middl e_initial',
'$nominee_last_ name', '$nominee_comme nts')";

// update database with infromation submitted
$db_query = mysqli_query ($db_connect, $nominee_field_ query);

}
else
{
echo 'The fields are empty';
}

When I submit, if I have data in one field, but not in all, it
displays "The fields are empty". I want it to submit into the database
if any fileds are filled in, but not if there are no fields filled in.

Nov 6 '07 #6
mtuller <mi******@gmail .comwrote in
news:11******** *************@1 9g2000hsx.googl egroups.com:

When I submit, if I have data in one field, but not in all, it
displays "The fields are empty". I want it to submit into the database
if any fileds are filled in, but not if there are no fields filled in.
but one post ago you said:

"Sorry, the subject of this is wrong. I don't want to check if any
fields are empty. I want to check if all are empty. That's why I have
&&."
So decide what exactly you are trying to do, and then pick either of the
solutions posted.
Nov 6 '07 #7
On Nov 6, 11:41 am, Good Man <he...@letsgo.c omwrote:
mtuller <mitul...@gmail .comwrote innews:11****** *************** @19g2000hsx.goo glegroups.com:
When I submit, if I have data in one field, but not in all, it
displays "The fields are empty". I want it to submit into the database
if any fileds are filled in, but not if there are no fields filled in.

but one post ago you said:

"Sorry, the subject of this is wrong. I don't want to check if any
fields are empty. I want to check if all are empty. That's why I have
&&."

So decide what exactly you are trying to do, and then pick either of the
solutions posted.
Ok. I see where it sounds like I am saying different things, but I am
not. Let me try again...

I want to check to see if ALL fields are empty, and if they are, the
form is not submitted into the database. If any of the fields have
data though, I want it to be submitted. That is why I am checking with
&&. If $nominee_first_ name AND $nominee_middle _initial AND
$nominee_last_n ame are all empty, echo "The fields are empty". If any
are filled in, then submit to the database.

Hope that explains better.

Nov 6 '07 #8
mtuller <mi******@gmail .comwrote in
news:11******** **************@ o38g2000hse.goo glegroups.com:

>So decide what exactly you are trying to do, and then pick either of
the solutions posted.

Ok. I see where it sounds like I am saying different things, but I am
not. Let me try again...

I want to check to see if ALL fields are empty, and if they are, the
form is not submitted into the database. If any of the fields have
data though, I want it to be submitted. That is why I am checking with
&&. If $nominee_first_ name AND $nominee_middle _initial AND
$nominee_last_n ame are all empty, echo "The fields are empty". If any
are filled in, then submit to the database.

Hope that explains better.
perfect!

so you know what you want to do, does this mean you've chosen a solution
from the thread, or can create your own? you've said exactly what you want
to do above (even in code term, no less) so just put it together!!!
Nov 6 '07 #9
On Nov 6, 12:12 pm, Good Man <he...@letsgo.c omwrote:
mtuller <mitul...@gmail .comwrote innews:11****** *************** *@o38g2000hse.g ooglegroups.com :
So decide what exactly you are trying to do, and then pick either of
the solutions posted.
Ok. I see where it sounds like I am saying different things, but I am
not. Let me try again...
I want to check to see if ALL fields are empty, and if they are, the
form is not submitted into the database. If any of the fields have
data though, I want it to be submitted. That is why I am checking with
&&. If $nominee_first_ name AND $nominee_middle _initial AND
$nominee_last_n ame are all empty, echo "The fields are empty". If any
are filled in, then submit to the database.
Hope that explains better.

perfect!

so you know what you want to do, does this mean you've chosen a solution
from the thread, or can create your own? you've said exactly what you want
to do above (even in code term, no less) so just put it together!!!
THEY DON'T WORK!!!! Do you think I am posting for my health?!

Nov 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2177
by: Gleep | last post by:
Hi PHP coders, I've got an issue I'm stuck with. Imagine there is a large form that has 5 columns and 20 rows. In each row there is a check box - then 4 input fields. I already have the code that inserts all the data BUT the validation is a nightmare. What I need is. If an entire row is empty (not checked or filled out) that's OK. However if a user fills in one or two input fields within a row - that's NOT ok. The entire row needs...
3
3333
by: Matt Herson | last post by:
I am looking for a validation script that will only look at the fields in the cgi form, determine if the fields are filled out, then if one or more are blank will write a message at the top of the page stating that some fields have not been filled out. I don't want a pop-up, I just want to send them back. I had seen something that did this using <div /> tags but cant seem to find one I can modify to work for this application. I was...
5
6329
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab Train Airplane
2
1596
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a tab structure with fields for various features a phone might have; there are almost 100 of these features to choose from. Rather than a simple check box, I used a combo box with the a value list of "Y, N, N/A, and ?"; I even simplified entry by...
5
24642
by: Krechting | last post by:
Hi ALl, I have a code that checks if the documents in a hyperlink field are still where they should be. I use fileexist(). First I want to filter out all the hyperlink fields that are empty. I open a recordset and browse through all the fields to check for the word file. I cannot filter out the empty fields. I have tried: If Len(.Fields("Link") <> 0 then and: If Not IsNull(.Fields("Link")) then
2
39123
by: bufbec1 | last post by:
I am pretty good with Access, but do not understand VBA. I have researched this topic and see only VBA answers, so I hope someone can help with my specific question. I have 2 fields for an end-user that must be filled in. I want an error message for each field. The forms are already partially filled in, and a user needs to select which record to go to. There are fields for them to fill in their initials and date , along with other...
1
2732
by: griemer | last post by:
I have a database like this id, field1,field2,field3,field4,field5 Database contains 100 rows, some rows have no fields filled, some 1field , some 2 fields etc. How would i count the number of fields filled in total? So the outcome is (number of fields filled in row1)+(number of fields
14
1906
by: ankitmathur | last post by:
Hi, I'm facing a pretty peculiar problem. In one of my pages I print the number of rows depending upon the number of Qty I got filled in my previous page i.e. If Qty is filled in as 3 in previous page 3 rows would be printed on my current page or, if 5 being entered in the previous page 5 rows would get printed in my current page & so on. Now the problem is, I want to check whether the required fields in each row has been filled or,...
4
2213
by: Samuel Murray | last post by:
G'day everyone I'm not a JavaScript programmer, so I wonder if you could point me in the right direction or simply tell me how to do the following. I'd like to submit a patch for the registration page of Pootle servers. Pootle is a GPL system for translation of software (usually volunteer work). What happens is that when a user registers, he fills in his real name,
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10406
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10420
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9221
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.