473,581 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the proper Syntax for if statements in regards to checkboxes

I'm trying to process a form that includes a checkbox and I've tried using
Expand|Select|Wrap|Line Numbers
  1. if($check == true)
to send a different email to people who did check the checkbox from those who didn't check the checkbox.
Oct 31 '10 #1
1 1798
Atli
5,058 Recognized Expert Expert
Where is your checkbox data coming from?

You should get your checkbox data from either the $_POST or $_GET super-globals, depending on how the method attribute on your form is set. (If you are unsure of which, try the $_REQUEST array. Id try to avoid it though.)

Also note that if a checkbox is not set, it will not be sent with the form. Only checked checkboxes are included. So to check if a checkbox is set you would do:
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['myCheckbox'])) {
  2.     // Box is set!
  3. }
  4. else {
  5.     // Box is not set!
  6. }
  7.  
Oct 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9339
by: Shea Martin | last post by:
I am trying to use a system call which takes a function ptr. My compiler won't compile the code if I give the system_call a ptr to a class member function, A::func(). To combat this, I created an function, xfunc(A a), which wraps A::func(). For this to work properly, I need to make xfunc() a friend of class A. I am getting compile...
6
1821
by: George Styles | last post by:
Hi, I am trying to work out what a block of C++ does, but I am having trouble understanding the syntax. I know Delphi well, so am happy with objects etc, its just this syntax I dont understand. The code is void CRipPanel::OnPaint()
1
5449
by: ivan | last post by:
The OpenReport syntax listed in Access97 help for "view", is "acViewPreview"or "acViewNormal". I have been using "acPreview " and "acNormal" . Is there any difference in the results or usage of "acVIEWPreview" versus "acPreview"?
2
3677
by: Kevin | last post by:
I am currently importing data into Access 2002 from 3 Sybase ASA 7.0 databases over a network. At this time I am using a ODBC System DSN connection using the proper ASA 7 driver. I would like to be able to make a DSN-Less connection so that my software is not dependent on having ODBC set-up with proper drivers and information. I have done...
2
4593
by: Rick Brown | last post by:
I'm trying to run code behind a command button from a command button on another form but get an error on this line. I figure I've got the syntax wrong for calling this command button? Whats the right syntax and/or can I call it directly without using the function. Form1 has a command button that calls the function: Call Send_Report_to_RTF...
1
1332
by: Dave56 | last post by:
I have an asp.net web service that is posting data to another web server. My code (somewhat simplified) looks like this: 'Convert string to byte array Dim bodyBytes() As Byte = encoding.GetBytes(myString) 'Configure Http Request
7
2629
by: Neil | last post by:
What I am doing wrong This works batPointer = adaptors.adaptor->batData; adaptors.batteries = batPointer->battery; where: batData is a pointer to a struct batPointer is a pointer to a different kind of struct
9
25743
by: svdoerga | last post by:
I am wondering how you can change the fontcolor in the header or footer in VBA when exporting to excel. I need some text in red. I found the ms page with the codes here. It's saying the formatting is &color and it should be a hexadecimal value. Then on the bottom of the page it says K. I've tried a lot of things like: &Kff0000 &K &ff0000 &...
3
3631
by: kstevens | last post by:
Please help. I know the sysntax is wrong. Here are some details. I am looking for the sum of past shipped items. I originally wrote this Dsum with only one criteria, but because of multiple lineitems with the same number it was adding all of the items with the same ....obviously. So i tried to just find records with multiple criteria........
0
936
by: dougancil | last post by:
I have the following code: Imports System.Data.SqlClient Public Class Form1 Dim ReturnValue As Object = Nothing Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim connectionString As String
0
7854
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...
0
7783
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...
0
8134
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8157
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6539
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...
0
3794
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3807
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1119
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...

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.