PHP: Submitting form data via $_POST works for all fields except radio buttons -
i new php , hope can me this.
i have html form number of inputs , textareas. on submit pass form php page generates email values.
for text inputs , textareas works intended radio buttons can't show me value on targetted page.
the radio buttons follows , classes used there apply css. there 1 form on submitting page, radios have same name ("requesttype
") , there no other elements using name.
also, added quick javascript snippet testing alert value on change , worked well, issue seems $_post
.
can tell me doing wrong here or alternatives try here ?
my html (on submitting page):
<input type="radio" class="customradio radiodefault" id="requesttype1" name="requesttype" value="value1" /> <label for="requesttype1">value1</label> <input type="radio" class="customradio triggerdiv" id="requesttype2" name="requesttype" value="value2" /> <label for="requesttype2">value2</label>
my php (on targetted page):
$_post["requesttype"]
update:
per riggsfolly tried check whether recognises radio button checked seems does, doesn't return following returns "xx":
if(isset($_post['requesttype'])){ $theselectedone = $_post['requesttype']; echo "radio value: x" . $theselectedone . "x"; }else{ echo "boohoo"; }
radio buttons (and checkboxes) passed form in either $_post or $_get arrays if checked. notice not auto check 1 of them create html nothing returned if user makes no selection.
so best way test if checked or not test existance of name in $_post array
if ( isset( $_post['requesttype'] ) ) { // selection made // test value see 1 checked $theselectedone = $_post['requesttype']; }
Comments
Post a Comment