Note that there are some explanatory texts on larger screens.

plurals
  1. POphp form validation using prerequisite
    primarykey
    data
    text
    <p>i am trying to validate some fields in my form. I am working with two fields, "address" and "state", initially the "address" and "state" field are not compulsory but if any value is entered into the "address" field the "state" field (which is a selection list) automatically becomes compulsory. I am just unsure on how to code the right IF condition.</p> <p>Here is what i have started on:</p> <pre><code>&lt;?php if (isset($_POST["submit"])) { $address = $_POST["address"]; $address = trim($address); $lengtha = strlen($address); $post = $_POST["post"]; $state = $_POST["state"]; if ($lengtha &gt; 1) { ?&gt; &lt;form method="POST" action="&lt;?php echo $_SERVER["PHP_SELF"];?&gt;" id="custinfo" &gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="custid"&gt;Customer ID (integer value): &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="custid" name="custid" value="&lt;?php echo $temp ?&gt;" size=11 /&gt;&lt;?php echo $msg; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="customerfname"&gt;Customer First Name: &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="fname" name="fname" size=50/&gt;&lt;?php echo $strmsg; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="customerlname"&gt;Customer Last Name: &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="lname" name="lname" size=50/&gt;&lt;?php echo $strmsgl; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="customeraddress"&gt;Customer Address: &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="address" name="address" size=65/&gt;&lt;/td&gt; &lt;td&gt;&lt;label for="suburb"&gt; Suburb: &lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="suburb" name="suburb"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; State:&lt;select name="state" id="state"&gt; &lt;option value="select"&gt;--&lt;/option&gt; &lt;option value="ACT"&gt;ACT&lt;/option&gt; &lt;option value="NSW"&gt;NSW&lt;/option&gt; &lt;option value="NT"&gt;NT&lt;/option&gt; &lt;option value="QLD"&gt;QLD&lt;/option&gt; &lt;option value="SA"&gt;SA&lt;/option&gt; &lt;option value="TAS"&gt;TAS&lt;/option&gt; &lt;option value="VIC"&gt;VIC&lt;/option&gt; &lt;option value="WA"&gt;WA&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; </code></pre> <p>Any help with figuring this out would be great!</p>
    singulars
    1. This table or related slice is empty.
    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