Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need the change your <code>options[]</code> to <code>option</code> as it mean you are submitting multiple select with the same name</p> <pre><code>&lt;form method="post" action="array2.php"&gt; &lt;select name="options"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;option value="7"&gt;7&lt;/option&gt; &lt;option value="8"&gt;8&lt;/option&gt; &lt;option value="9"&gt;9&lt;/option&gt; &lt;option value="10"&gt;10&lt;/option&gt; &lt;/select&gt; &lt;input name="submit" type="submit" value="submit"&gt; &lt;/form&gt; </code></pre> <p>in your <code>array2.php</code> file</p> <pre><code>&lt;?php session_start(); if(isset($_POST['submit'])){ if($_POST['options'] == "" ){ header("Location: error.html"); exit; }else{ $checked = $_POST['options']; $_SESSION['checked'] = $checked; } } ?&gt; </code></pre> <p>if you really need to send <code>options[]</code> </p> <pre><code>&lt;?php session_start(); if(isset($_POST['submit'])){ if(is_array($_POST['options']){ if($_POST['options'][0] == "" ){ header("Location: error.html"); exit; }else{ $checked = $_POST['options'][0]; $_SESSION['checked'] = $checked; } }else{ if($_POST['options'] == "" ){ header("Location: error.html"); exit; }else{ $checked = $_POST['options']; $_SESSION['checked'] = $checked; } } } ?&gt; </code></pre> <p>you can clean this if else as you like</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