这个问题似乎很容易,但我还是不明白。我看了一下多个答案一个建议这个修复我在哪里添加一个变量和输入元素的名称我好像一行很简单,我设置它将行添加到数据库并且它提交但是数据库是空的。
HTML CODE
<label>Type of Business please Select One </label>
<select name="businesstype">
<option value="corp">Corporation</option>
<option value="llc">LLC</option>
<option value="solepro" >Sole Proprietorship</option>
</select>
PHP代码
$corp = $_POST['businesstype'];
$llc = $_POST['businesstype'];
$solepro = $_POST['businesstype'];
// Other POST elements
$conn = new mysqli($servername, $db_username, $db_pass, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO enrolled (fulllegalcompname, dba, businessaddress, email, website, storenum, storefax, businesstype) VALUES ('$fulllegalcompname', '$dba', '$businessaddress', '$email', '$website', '$storenum', '$storefax', '$businesstype');";
答案 0 :(得分:-1)
$ businesstype 变量存储错误的值。请查看以下答案。
<?php
$businesstype = $_POST['businesstype'];
// Other POST elements
$conn = new mysqli($servername, $db_username, $db_pass, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO enrolled (fulllegalcompname, dba, businessaddress, email, website, storenum, storefax, businesstype) VALUES ('$fulllegalcompname', '$dba', '$businessaddress', '$email', '$website', '$storenum', '$storefax', '$businesstype');";
?>