我可以將輸入字段的值解析爲查詢參數以獲取同一表單中選擇字段的值嗎?解析查詢參數的輸入字段值
的代碼如下:
<FORM ACTION="login.php" METHOD=get>
<label for="email">Email: </label>
<input id="email" name="email" type="text" ><br>
<label for="pin">Password: </label>
<input id="pin" name="pin" type="password" ><br>
<label for="company">Company</label>
<select name="Company" id="company">
<option>Select Company:</option>
<?php
$conn= new mysqli($servername,$username,$password,$db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connet_error);
}
$email = isset($_GET['email'])?$_GET['email']:"";
$sql="select company from accounts WHERE email = '$email';";
$results = mysqli_query($conn, $sql);
if ($results->num_rows > 0){
while ($row = mysqli_fetch_array($results)){
echo "<option value=\"company1\">" .$row['company'] . "</option>";
}
}
?>
</select>
<input class="submit_btn" type="submit" value="Login"></input><br>
<a id="cust-nopin" href="javascript:;"><p class="text_centered_pass">Click here if you don't have a password</p></a>
</FORM>
那是不可能的?
你想達到什麼目的?我無法理解你。請詳細說明你的問題。 – TipuZaynSultan
我想使用輸入id =「email」的值作爲查詢的參數,它將填充選擇id =「company」的選擇選項。 – Den