现在我只在我的电子邮件帐户中收到了值,但我希望选择的文字如何做到这里是我的代码:
<select name="selectoption">
<option value='0'>Choose Server..</option>
<option value='1'>L2 EmpireAge 70x</option>
<option value='2'>L2 EmpireAge Warfire 150x</option>
<option value='3'>L2 EmpireAge Classic 30x</option>
</select>
$name = $_POST['name'];
$email_address = $_POST['email'];
$password = $_POST['password'];
$select_server = $_POST['selectoption'];
$select_weapon = $_POST['weaponid'];
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. /n ".
" Here are the details:\n Name: $name \n Email: $email_address \n Password: $password \n Server_Id: $select_server \n Weapon_Id: $select_weapon ";
答案 0 :(得分:0)
您需要类似数组的内容来存储值,请参阅以下示例:
<?php
$array[0] = 'Choose Server..';
$array[1] = 'L2 EmpireAge 70x';
$array[2] = 'L2 EmpireAge Warfire 150x';
$array[3] = 'L2 EmpireAge Classic 30x';
?>
<select name="selectoption">
<?php
for($i = 0; $i < count($array); $i++) {
echo "<option value='{$i}'>{$array[$i]}</option>";
}
?>
</select>
$name = $_POST['name'];
$email_address = $_POST['email'];
$password = $_POST['password'];
$select_server = $_POST['selectoption'];
$select_weapon = $_POST['weaponid'];
//Your server info is here
$info = $array[$select_server];