Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The error is because the <code>$_POST['arrayValue']</code> doesn't exist. That will happen if none of the boxes are checked. </p> <p>Your form is missing the <code>&lt;form&gt;</code> tag and does not have a submit button. Without these elements, it won't work.</p> <p>Also, you're declaring an array <code>$arrayValue = array();</code> in your code. I don't think that's necessary here. If you're just trying to get the input values and concatenate them together, you don't need that. As I'm unsure what you're planning to do with it, I've ignored that in my answer.</p> <p>I've included a working demo below, and that'll probably get you started.</p> <hr> <p><strong>Full code:</strong></p> <pre><code>&lt;?php if( isset($_POST['submitButton']) ){ $areas = implode("," , $_POST['arrayValue']); print_r($areas); } ?&gt; &lt;form action="" method="post"&gt; &lt;div class='span5' style='margin-left:0px !important;'&gt; &lt;label&gt; &lt;input type="checkbox" name="arrayValue[]" id="area[0]" value="Sparks" style='margin-top:-5px !important;'&gt; Sparks &lt;/label&gt; &lt;/div&gt; &lt;div class='span5' style='margin-left:0px !important;'&gt; &lt;label&gt; &lt;input type="checkbox" name="arrayValue[]" id="area[1]" value="Stead" style='margin-top:-5px !important;'&gt; Stead &lt;/label&gt; &lt;/div&gt; &lt;div class='span5' style='margin-left:0px !important;'&gt; &lt;label&gt; &lt;input type="checkbox" name="arrayValue[]" id="area[2]" value="North Reno" style='margin-top:-5px !important;'&gt; North Reno &lt;/label&gt; &lt;/div&gt; &lt;input type="submit" name="submitButton"/&gt; &lt;/form&gt; </code></pre> <p><strong>Output:</strong></p> <pre><code>Sparks,Stead,North Reno </code></pre> <p>The above code uses an empty action and thus posts to itself. You'll want to change that according to your requirements.</p> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload