U
U
Uzair Izha2015-10-22 21:10:24
PHP
Uzair Izha, 2015-10-22 21:10:24

How to use the session in php to save the value of the selected radio?

<input type="radio" name="one" value="$i" id="radio"  <?php if($_SESSION['i']==$i) { ?>  checked="checked" <?php } ?> >


That is, I want, for example, he chose the radio so that its value is recorded in the session and then the selection conditions work and the radio is active. (checked)

By the way, I forgot to write, without reloading it would be necessary)) using jq

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2015-10-22
@R0dger

<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" 
<?php (isset($_SESSION['i'])&&$_SESSION['i'])==$i?'checked="checked"':''?>
value="female">Female

Well, that's how it should be...

V
Vladislav Startsev, 2015-10-23
@esvlad

And what for in session to store, would not be better in cookie or localStorage?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question