Я заполняю веб-страницу, чтобы пользователь мог зарегистрироваться в системе. Вместо обычных типов ввода я хочу использовать выпадающее меню выбора тега для пользователей, чтобы выбрать конкретные значения, которые я жестко кодирую.
Однако, когда я изменяю код с <input type="text" name="a" placeholder="Age" />
на выбранный тег, он больше не добавляется в мою базу данных. Я использую name="a"
для идентификации ввода в моих операторах SQL. Кто-нибудь знает, что мне нужно добавить, чтобы позволить значения из тега выбора, чтобы добавить в мою базу данных? Спасибо.
<form action="index.php" method="post" class="w3-container w3-center w3-dark-grey">
<br><h1>Sign up as Personal Trainer</h1>
<input type="text" name="i" placeholder="Personal Trainer ID" /><br>
<input type="text" name="n" placeholder="Name" /><br>
<input type="text" name="l" placeholder="Location" /><br>
<select class="w3-input w3-border" name="a" style="width: 30%">
<option value="0">0</option>
<option value="2">2</option>
</select>
<input type="text" name="s" placeholder="Sex" /><br>
<input type="text" name="y" placeholder="Experience" /><br>
<input type="text" name="sp" placeholder="Specialty" /><br>
<input type="text" name="f" placeholder="Fee" /><br>
<input type="text" name="w" placeholder="Training Weeks" /><br>
<input type="text" name="e" placeholder="Email" required/><br>
<input type="password" name="p" placeholder="Password" required/><br>
<input type="text" name="im" placeholder="Image" hidden="true"/><br>
<br>
<input type="submit" name="sub" class="w3-button w3-black" value="Sign Up"/>
<a href="client.php"><button type="button" class="w3-button w3-black" value="button">Sign up as Client</button></a>
<br>
<br>
<a href="loginT.php"><button type="button" class="w3-button w3-black" value="button">Login as Trainer</button></a>
<a href="loginC.php"><button type="button" class="w3-button w3-black" value="button">Login as Client</button></a>
<br><br>
<!-- this button is used to retrieve the data from the database
this is performed by the personal trainer id unique key -->
</form>
</center>
<?php
/*on the submit rquest, the data is written to the database */
if(isset($_POST["sub"]))
{
$con=new mysqli("localhost:3308","root","","fypdatabase");
$st_check=$con->prepare("select * from personal_trainer where email=?");
$st_check->bind_param("s", $_POST["e"]);
$st_check->execute();
$rs=$st_check->get_result();
if($rs->num_rows>0)
echo "<script>alert('Email already taken');</script>";
else{
$con=new mysqli("localhost:3308","root","","fypdatabase");
$st=$con->prepare("insert into personal_trainer values(?,?,?,?,?,?,?,?,?,?,?,?)");
$st->bind_param("issisisiisss", $_POST["i"],$_POST["n"],$_POST["l"],$_POST["a"],$_POST["s"],$_POST["y"],$_POST["sp"],$_POST["f"],$_POST["w"],$_POST["e"],$_POST["p"],$_POST["im"]);
$st->execute();
$_SESSION['user']=$_POST['e'];
echo "<script>window.location='loginT.php'</script>";
}
}
?>