Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a start, the value of $fromstore is always going to be at least a space character and never empty in your example, as you're providing it with a text value in your HTML (even a space is still sent as a text value). Remove the space from what you're sending to PHP and the if(empty()) condition will start evaluating properly.</p> <p>Secondly, the element is best used when your form input has an associated ID. That way when you click on the label itself, the form element automatically gains focus (far better for accessibility and usability). Each input should have an associated label that describes simply what the input is for / represents.</p> <p>Modify your HTML to look a bit more like this:</p> <pre><code>&lt;li&gt; Printed: &lt;label for="printed_no"&gt;No&lt;/label&gt; &lt;input type="radio" name="printed" value="no" class="morefrom" checked="checked" id="printed_no"&gt; &lt;label for="printed_yes"&gt;Yes&lt;/label&gt; &lt;input type="radio" name="printed" value="yes" class="morefrom"&gt; &lt;/li&gt; &lt;li&gt; &lt;div id="collectfrom"&gt; &lt;label for="fromstore"&gt;Collect From:&lt;/label&gt; &lt;select name="fromstore" id="fromstore"&gt; &lt;option&gt;Choose from&lt;/option&gt; &lt;option value="nicosia"&gt;Nicosia&lt;/option&gt; &lt;option value="limassol"&gt;Limassol&lt;/option&gt; &lt;option value="paphos"&gt;Paphos&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>Also, You haven't included the element in your code snippet above, are you definitely setting it and having your PHP script run? I would assume you are, but just want to make sure ;)</p> <p>Finally, you appear to be relying on PHP's register_globals setting being enabled, which is very old practice and you should be thinking about updating yourself to use more widely accepted methods. Most servers nowadays won't have register_globals enabled and you may find your scripts breaking if you ever migrate from one server to another.</p> <p>Have a look here for more info:</p> <p><a href="https://stackoverflow.com/questions/1417373/why-is-register-globals-so-bad">Why is REGISTER_GLOBALS so bad?</a></p> <p>In this case, update your PHP to:</p> <pre><code>if($_POST['printed'] == "yes"){ if(empty($_POST['fromstore'])){ $action['result'] = 'error'; /* I assume $text used below is a variable instantiated * somewhere else in this script and isn't sent from the * form. Thus I've left it as $text instead of $_POST['text'] */ array_push($text,'You forgot your city'); } } </code></pre> <p>Hope this helps,</p> <p>Neal</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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