Handling unchecked checkboxes in PHP: the hidden field trick

preview_player
Показать описание

In this video we're going to learn a trick for dealing with unchecked checkboxes in HTML forms. The trick takes advantage of how PHP handles array indexes, and how HTML allows various input fields to have the same name.

Code shown in the video:
Рекомендации по теме
Комментарии
Автор

thanks, your course is amazing .may i ask a question? how can i use this with mysql?

neamaahmed
Автор

Would something like
$allow_access = isset($_POST['allow_access']) ? $_POST['allow_access'] : 0;
also work?
Also, are we guaranteed that the inputs in the post response are always received in the same order as they appear in the form?
Thanks.

NoahNobody
Автор

that was really a awesome explanation please make more such we need them a lot a special request is please make a video how to access files and images in different different folders and directory in php using include and requir for big projects hope you understand the problem

satyammishra
Автор

Thank you, truly knowledge is power😂

DesWorks.
Автор

Dave, you're my favorite PHP Rock Star!

MichaelProstka
Автор

dang, why Did I take so long to find your channel!? new suscriber.

DanielPerez-dgzl
Автор

whats the solution, if the checkbox is a dynamic array, like the user can press a button to add more? I have a form which needs other text data alongside checkboxes. So if the user adds, it would be a whole another row of text data + checkboxes. Unticked checkbox has no data to send at all, so testing an inbetween unticked box is a disaster, it will just skip as if it didnt exist.

TheTriangle
Автор

Sir can you please create YouTube course on codeigniter 4 ? Your course are amazing and very helpful for beginners like me.

ShubhamMishra-uwyi
Автор

How about a form input that is an array?

tyscyre
Автор

What If we have a array as 'name', then how to access the unchecked value

Spark_