Note that there are some explanatory texts on larger screens.

plurals
  1. POValidate Empty / Radio Fields - Php
    primarykey
    data
    text
    <pre><code>&lt;?php $name = $_POST["name"]; $email = $_POST["email"]; $gender = $_POST["gen"]; $age = $_POST["age"]; $comments = $_POST["comments"]; if(empty($_POST["name"])){ echo "empty name"; } if(empty($_POST["email"])){ echo "empty email"; } /// if(empty($_POST["gen"])){ echo "empty gender"; } if(empty($_POST["comments"])){ echo "empty comments"; } if(!isset($_POST['submit'])) { ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Lab6 : P1&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;h4&gt;Enter your information in the fields below&lt;/h4&gt;&lt;/legend&gt; &lt;form name="info" method="post" action="&lt;?php echo $PHP_SELF;?&gt;" method="post"&gt; &lt;strong&gt;Name:&lt;/strong&gt; &lt;input type="text" name="name" id="name" /&gt;&lt;br&gt; &lt;strong&gt;Email:&lt;/strong&gt; &lt;input type="text" name="email" id="email" /&gt;&lt;br&gt; &lt;br&gt; &lt;strong&gt;Gender&lt;/strong&gt;&lt;br&gt; &lt;input type="radio" name="gen" value="Male"&gt;Male&lt;/input&gt;&lt;br&gt; &lt;input type="radio" name="gen" value="Female"&gt;Female&lt;/input&gt;&lt;br&gt; &lt;br&gt; &lt;select name="age"&gt; &lt;option value="Under 30"&gt;Under 30&lt;/option&gt;&lt;br&gt; &lt;option value="Between 30 and 60"&gt;Between 30 and 60&lt;/option&gt;&lt;br&gt; &lt;option value="60+"&gt;60+&lt;/option&gt; &lt;/select&gt; &lt;br&gt; Comments: &lt;textarea name="comments" cols="20" rows="5"&gt; &lt;/textarea&gt; &lt;/fieldset&gt; &lt;input type="submit" name="submit" value="Submit my Information" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; &lt;? } else { echo "Thank you, ".$name." for your comments: " . "&lt;strong&gt;" . $comments . "&lt;/strong&gt;"; echo "&lt;br&gt;We will reply to you at:" . "&lt;em&gt;" . $email . "&lt;/em&gt;"; } ?&gt; </code></pre> <p>I need it to validate the fields: name, email, comments for empty strings (not allowed) and not allow unselected radio buttons for gender and age selection.</p> <p>Can anyone help</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.
 

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