Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml multiple select field issue with php
    primarykey
    data
    text
    <p>I've a html form with multiple select field. I'm trying to validate it with php. but i can't validate this multiple select field with php. It's show me success message without any validation. </p> <p>Please kindly tell me what's the problem in my code. Thank you. </p> <p><strong>Php Code:</strong></p> <pre><code>&lt;?php if(isset($_POST['Submit']) &amp;&amp; $_POST['Submit'] == "Send SMS") { if(isset($_POST['number'])) $number = $_POST['number']; $msg = inputvalid($_POST['txt']); $err = array(); if(isset($msg) &amp;&amp; isset($number)) { if(empty($msg) &amp;&amp; empty($number)) $err[] = "All field require"; else { if(empty($msg)) $err[] = "Your message require"; if(empty($number)) $err[] = "Select your mobile number"; } } if(!empty($err)) { echo "&lt;div class='error'&gt;"; foreach($err as $er) { echo "&lt;font color=red&gt;$er.&lt;/font&gt;&lt;br/&gt;"; } echo "&lt;/div&gt;"; echo "&lt;br/&gt;"; } else { echo "good"; } } ?&gt; </code></pre> <p><strong>Html Code:</strong></p> <pre><code>&lt;form name="frm" method="post" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?&gt;"&gt; &lt;table width="800" border="0" cellspacing="10" cellpadding="0"&gt; &lt;tr&gt; &lt;td valign="top"&gt;Number&lt;/td&gt; &lt;td&gt; &lt;select multiple="multiple" size="10" name="number[]"&gt; &lt;option value=""&gt;--Select Member--&lt;/option&gt; &lt;?php $class = mysql_query("SELECT * FROM e_members"); while($res = mysql_fetch_array($class)) { $phone = $res['phone']; ?&gt; &lt;option value="&lt;?php echo $phone; ?&gt;"&gt; &lt;?php echo $phone; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;Write message&lt;/td&gt; &lt;td&gt; &lt;textarea class="textarea" placeholder="Your message" name="txt" onkeyup="counter(this);"&gt; &lt;?php if(isset($_POST['txt'])) echo $_POST['txt']; ?&gt; &lt;/textarea&gt; &lt;br/&gt; &lt;input type="" name="lbl" style="border:none;"&gt; &lt;br/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;input type="submit" name="Submit2" value="Save SMS" class="view"/&gt; &lt;input type="submit" name="Submit" value="Send SMS" class="submit"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p><strong>Update:</strong></p> <p>After select multiple/single value var_dump showing:</p> <pre><code>array(1) { [0]=&gt; string(13) "8801814758545" } </code></pre> <p>Without select it's showing:</p> <pre><code>NULL </code></pre>
    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.
 

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