rich menga books search contact

***Secret FSR Fender guitars? Yes, they exist, and they're right here

Amazon links are affiliated. Learn more.

PHP carry values from checkboxes how-to

For the last couple of days I've been working on this monster PHP form for my biz site. It's definitely the biggest form I've ever done and it's taken a lot of programming. So far it's almost 30k just in code alone without any design like GIF's and JPG's and so on.

The form is simple in nature. It's a multi-page thing that carries values from one part to the next all contained within one file.

A big obstacle (for me) was getting all checkbox values there were checked in the PHP form to carry from one part of the form to the next. Absolutely nowhere on the internet were any SIMPLE instructions on how to do it, so I did a lot of reading and found a way to make it simple. The answer was to put the values into an array and then implode it on destination, like this:

<html>
<head>
<title>the form</title>
</head>
<body>

<?php
$page = ("$PHP_SELF");
if ($step == "") {
echo("
<form method="post" action="$page?step=2">
<input type="checkbox" name="choices[]" value="Choice A">
Choice A<br>
<input type="checkbox" name="choices[]" value="Choice B">
Choice B<br>
<input type="checkbox" name="choices[]" value="Choice C">
Choice C<br>
<input type="submit" name="Submit" value="Submit">
</form>
");

} elseif ($step == "2") {

if ($choices == "") {
echo ("You didn't make a choice. Please <a href="javascript:history.go(-1)">go back</a> and make a choice.");
echo("n</body>n</html>");
exit;
}

$getchoices = implode(", ", $choices);
$choices = ("$getchoices");

echo ("You chose $choices");

} else {

}

?>

</body>
</html>

The [] for the name on input puts the values into an array. Implode takes the values of the array and separates the ones selected by commas and ta-da, you got it.

I'm posting this process here just in case I ever forget how to do it and need a reference. 😉

051216
📰Get Rich's newsletter to be notified of new articles

image
Best ZOOM R8 tutorial book
highly rated, get recording quick!

⭐ Recent Posts

Boss RC-5 Loop Station Guitar Looper PedalWill looper drums ever not suck?
It is amazing that this problem still exists.

The best looking Dean Z I've ever seen
This is an example of when Dean does the Z right.

Black Sabbath - Black SabbathMy favorite Black Sabbath track from their first album
It's not what you think it is.

Epiphone Prophecy Les PaulA secret of the Epiphone Prophecy Les Paul hiding in plain sight
It's right in front of your face and you probably didn't even notice it

Fender Player MustangShorter scale guitars with the most bang for the buck
You can go short without spending too much nor getting something too cheap.

🔥 Popular Posts 🔥

Casio F-91WCasio F-91W cheat sheet
A quick guide on how to set the time, date and a few other tips and tricks.

Casio G-SHOCK GWM5610All atomic watches are saved... for now
There will come a time when buying a watch with atomic time sync functionality will be completely pointless.

Casio A700WThe one reason why you should buy a Casio A700W
All F91W type watches should be this good.

Fender Stratocaster HSSThe HSS guitar is not a good idea
Guitars with this type of setup may be usable, but the cons outweigh the pros.

Fender EsquireThe 5 types of guitars you should never buy
Some guitars that exist where the day after you buy them, you know you've made a mistake.

Squier Affinity Telecaster7 reasons why every metal player should own a Telecaster
Smarter metal players use a Telecaster

Why I don't like PRS guitars
There are certain guitar companies out there who have very little concerning a guitar I'd actually want to own, and PRS is one of them.