0

I am trying to post a nested radio button with different field name and I have tried all I can, but I have not been successfull.

<form id="w0" class="form-vertical" action="" method="post">
    <input type="hidden" name="_csrf" value="">
    <label>Choose If you are human</label> 
        <div class="radio">
            <label>
                <input type="radio" name="name1" value="1">
                <h4> Gender: &nbsp; &nbsp;
                    <input type="radio" name="male" value="m">Male
                    <input type="radio" name="gender" value="f">Female
                </h4>
            </label>
       </div>
   <hr>
</div>
<div class="help-block"></div>
</div><br>
<div class="form-group">
    <button type="submit" class="btn btn success">Submit</button>
</div>
</form>


<?php
if(isset($_POST['name1']) && isset($_POST['gender'])){

    $model->name = $_POST['name1'];
    $model->gender= $_POST['gender'];
    $model->save();
}
  • 1
    Can you post your full code of the form with which you want to post the data? – Himanshu Upadhyay May 01 '18 at 09:35
  • _"not been successfull"_ - please describe what the problem is! – Jeff May 01 '18 at 09:44
  • I am trying to post from a form and it gives _**Undefined index**_: _**name1**_ – user2527845 May 01 '18 at 09:45
  • Can you please provide us with your PHP code - this is all HTML and won't be causing any errors. – Mark May 01 '18 at 09:48
  • The shown code doesn't produce the `Undefined index: name1` error. The error msg contains a line number. Search for that line. – Jeff May 01 '18 at 10:33
  • Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – Jeff May 01 '18 at 10:34

0 Answers0