Solved

php - processing checkboxes

Posted on 2014-04-15
3
307 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 109

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 109

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Query return divisible by 3 3 25
PHP and JQuery Syntax question 4 26
Wordpress Security 29 46
How do I correctly structure this?   PHP / PDO / CSV download 1 19
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

792 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