php – 将HTML选择/下拉列表提交到MySQL数据库

我正在尝试提交HTML< form>并将输入和选择信息输入MySQL数据库表.我的代码正在输入< input type =“text”>数据进入表格,但它没有在< select>中输入数据.

这是< form>我一直在使用:

<form enctype="multipart/form-data" action="send.PHP" method="post">
    <select name="gender">
        <option value="Male"> Male</option>
        <option value="Female">Female</option>
    </select>
    <input type="text" name="name">
    <input type="submit" value="Add">
</form>

这是我用来将表单输入表格的PHP

<?PHP
$gender=$_POST['gender']; // This is the select/dropdown
$name=$_POST['name'];  // This is the text input

MysqL_connect("", "", "") or die(MysqL_error()) ; 
MysqL_select_db("") or die(MysqL_error()) ; 

MysqL_query("INSERT INTO `table1` VALUES ('$gender', '$name')") ; 
?>

解决方法:

嗯……如果那不起作用,试试:

MysqL_query("INSERT INTO table1 VALUES ('".$gender."','".$name."');");

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...