I created a forum, where students have to fill out their year of graduation. When I was validating my file, as shown by the comment, the line below produces an error, "Text not allowed in element select
in this context." I need to name "year" in the select tag, so I can use the post array to get the year. How can I fix this validation error?
<form method="post">
<div class = "mailInput">
Name: <input type="text" name="name">
<span class="error"> <?php echo $nameErr;?></span></div>
<div class = "mailInput">
Email: <input type="text" name="email">
<span class="error"> <?php echo $emailErr;?></span> </div>
<div class = "mailInput">
Major: <input type="text" name="major">
<span class="error"> <?php echo $majorErr;?></span> </div>
<div class = "mailInput">
Year: <select class="select" name="year"> // this line produces an error
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
</select>
</div>
<div class = "mailInput lastInput"> Gender:
<input type="radio" name="gender" value="Female">Female
<input type="radio" name="gender" value="Male">Male
</div>
<span class="error"> <?php echo $genderErr;?></span>
<div class = "submitButton"><input type="submit" name="submit" value="Join">
</div>
<div class="message"> <?php echo $submitMessage;?></div>
</form>
if(isset($_POST['submit']) && !empty($_POST['submit'])) {
if (!empty($_POST["year"])) {
$year = $_POST["year"];
}
}