有人可以告诉我如何将选择的下拉值与我的文本输入值一起发布到mysql数据库中。
我有以下内容,我不确定应该如何处理下拉值。
谢谢
<form action=\"includes/welcomestats.php\" method=\"post\" id=\"form1\">
<input type=\"text\" name=\"location\" id=\"location\" maxlength=\"30\" placeholder=\"Location: e.g. London\">
Enter Your Location</label><br/>
<br/>
<input type=\"text\" name=\"local_station\" id=\"local_station\" maxlength=\"30\" placeholder=\"Local Train Station\"><label> Enter a Local Train Station</label><br/><br/><br/>
<h5>About You</h5><br/>
<select name=\"formGender\" style=\"min-width:125px;\">
<option value=\"\">Select...</option>
<option value=\"M\">Male</option>
<option value=\"T\">Female</option>
</select>
<label> Enter Your Gender</label>
<br/><br/>
<input type=\"submit\" class=\"welcome-submit2\" name=\"submit\" value=\"Next ->\" id=\"submit\"/>
</form>
<?php
require_once("session.php");
require_once("functions.php");
require('_config/connection.php');
?>
<?php
session_start();
include '_config/connection.php';
$location = $_POST['location'];
$result = mysql_query("SELECT location FROM ptb_profiles WHERE id=".$_SESSION['user_id']."");
if(!$result)
{
echo "The username you entered does not exist";
}
else
if($location!= mysql_result($result, 0))
{
echo "";
$sql=mysql_query("UPDATE ptb_profiles SET location ='".addslashes($display_name)."' WHERE id=".$_SESSION['user_id']."");
}
答案 0 :(得分:0)
选择字段值的处理方式与任何其他字段相同。所以,如果您有选择字段 -
<select name=\"formGender\" style=\"min-width:125px;\">
<option value=\"\">Select...</option>
<option value=\"M\">Male</option>
<option value=\"T\">Female</option>
</select>
您可以使用
$gender = $_POST['formGender']
<强>更新强> 这将给你M或F.