Solved

php - processing checkboxes

Posted on 2014-04-15
3
310 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 110

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 110

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 logic to add to date card 9 39
Send email using HTML and PHP in separate file 5 39
PHP Curl Problem 10 36
Find RGB colors from a screen. 2 17
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…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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