Solved

php - processing checkboxes

Posted on 2014-04-15
3
302 Views
Last Modified: 2014-04-15
Hello,

I have a php program (attached) designed to process checkboxes on a form. Note the echo was to debug & find out why it wasn't working.

Also attached is the HTML page, as it existed upon calling the php program.

Note in the html program, there are several checkbox elements that are NOT checked. Those elements are NOT being picked up in the php program which defeats the whole purpose.

Why are the unchecked elements NOT being picked up?
updt-base-citylinks.php
manage-base-citylinks.htm
0
Comment
Question by:Richard Korts
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40002869
Unchecked checkboxes are not present in the request variables.  They are not "there and empty;" they are simply missing.  This is the way that it works.  Dumb design, but an unfortunate fact of life.  Please read this over and see if it helps with the understanding.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_5450-Common-Sense-Examples-Using-Checkboxes-with-HTML-JavaScript-and-PHP.html
0
 

Author Comment

by:Richard Korts
ID: 40002890
I thought that MIGHT be the case, but I thought THAT was a stupid idea to even consider

I can envision a workaround.

Thanks
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40002897
The workaround might be an input of an identical name attribute with type="hidden" as described in the article.  I have used that successfully.  It's a PHP-only solution because some languages that use raw post input require specialized programming to deal with the request data.  But if you're using PHP and you use the $_GET or $_POST arrays, you'll be on firm ground.

Thanks for the points, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now