-1
Guys, I have this code and I need to assign the value of select to a php variable. How do I do that?
<form name="form-avaliacao" method="post" action="confirmacao-avaliacao.php">
<label>Disciplina *</label><br>
<select name="disciplina" id="disciplina" required>
<option>Selecione uma disciplina</option>
<option>Artes</option>
<option>Biologia</option>
<option>Educação Física</option>
<option>Filosofia</option>
<option>Física</option>
<option>Geografia</option>
<option>História</option>
<option>Inglês</option>
<option>Matemática</option>
<option>Português</option>
<option>Química</option>
<option>Sociologia</option>
</select> <br><br>
You have to send the select value to the server and do the assignment in PHP. The problem is that the question is too shallow for information.
– Sam
The idea is this: Once the user selects one of the select options, the selected option must be saved in a variable. Then I make an if with this variable, to store its value in the bank.
– Paulo Leal
Example: just below this select would have this: <? php $select = the value of the top select if($select == "Math") { $category = $select; INSERT INTO tb_ratings (category) VALUES = '$category'; }
– Paulo Leal
Important [Dit] and post what you tried, and an explanation of what did not work. Tutorials, tips and guesses are not part of the site profile
– Bacco