Как в input type='radio', дать значение при отправке формы в php
Мне нужно задать значение input и получить данные из них с помощью php, код
<form action="/case/knife_case.php" method="get" class="factor_case">
<div class="factor_align">
<input id="1x" name="factor1" type="radio">
<label style="--i:1s" class="factor_label" for="1x">1x</label>
<input id="2x" name="factor2" type="radio">
<label style="--i:2s" class="factor_label" for="2x">2x</label>
<input id="3x" name="factor3" type="radio">
$amount = $_GET['factor1'];
echo $amount;
Даже если я ставлю value не работает
<form action="/case/knife_case.php" method="get" class="factor_case">
<div class="factor_align">
<input value="sadas" id="1x" name="factor1" type="radio">
<label style="--i:1s" class="factor_label" for="1x">1x</label>
$amount = $_GET['factor1'];
if (isset($amount)) {
echo 'good';
} else {
echo 'none';
}
Ответы (1 шт):
Автор решения: Dissmind
→ Ссылка
У тега input, есть артибут "value" для хранения значения.
<form action="/case/knife_case.php" method="get" class="factor_case">
<div class="factor_align">
<input id="1x" name="factor1" type="radio" value="test-value">
<label style="--i:1s" class="factor_label" for="1x">1x</label>
<input id="2x" name="factor2" type="radio" value="test-value2">
<label style="--i:2s" class="factor_label" for="2x">2x</label>
<input id="3x" name="factor3" type="radio" value="test-value3">
</div>
/* в файле knife_case.php */
$testValue1 = $_GET['factor1']; // test-value
$testValue2 = $_GET['factor2']; // test-value2
$testValue3 = $_GET['factor3']; // test-value3
