连接是正确的字段设置正确,但无法从代码中找到问题。一小时前它工作正常但是在放入更多字段之后它就卡住了。正确提交,但是xampp中的字段没有任何内容。请帮我提交数据。看看下面的变量,实际上是下面的所有代码。
<?php
$product = "";
$cost = "";
$other = "";
$otherOne = "";
$code = "";
$price = "";
$qty = "";
$kg = "";
$value = "";
$id = 0;
这是我的config.php文件代码,它与我的数据库正确连接,因为它无法显示任何die()错误。
<?php
//Database Connection
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'waqar';
$connection = mysqli_connect($host, $user,$pass,$db) or die("<h2>Database Connection Failed. Contact Your Administrator</h2>");
?>
//表格提交时
if(isset($_POST['submit'])) {
$product = $_POST['product'];
$cost = $_POST['cost'];
$other = $_POST['other'];
$otherOne = $_POST['otherOne'];
$code = $_POST['code'];
$price = $_POST['price'];
$qty = $_POST['qty'];
$kg = $_POST['kg'];
$value = $_POST['value'];
//Query
$query = "INSERT INTO managment(product, cost, other, otherOne, code, price, value) VALUES ('$product','$cost','$other', '$otherOne', '$code', '$price', '$qty', '$kg', 'value')";
mysqli_query($connection, $query);
header("location: home.php");
}
?>
<?php include("header.php"); ?>
<div class="content">
<br/>
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-2"></div>
<div class="col-lg-10 col-md-10 col-sm-8">
<div class="login-form">
<form method="post">
<div class="row">
<div class="col-lg-6">
<input class="form-control" type="text" name="product" placeholder="Product..."><br>
</div>
<div class="col-lg-6">
<input class="form-control" type="text" name="code" placeholder="Code..."><br>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<input class="form-control" type="text" name="cost" placeholder="Cost..."><br>
</div>
<div class="col-lg-6">
<input class="form-control" type="text" name="price" placeholder="Price..."><br>
</div>
</div>
<input class="form-control" type="text" name="other" placeholder="Other..."><br>
<input class="form-control" type="text" name="otherOne" placeholder="Other..."><br>
<label class="radio-inline">
<input type="radio" name="qty" id="qty" value="qty"> Quantity
</label>
<label class="radio-inline">
<input type="radio" name="kg" id="kg" value="kg"> Kilograms
</label>
<br><br>
<input class="form-control" type="number" step="1.00" name="value" placeholder="Quantity / Kilograms"><br>
<input class="btn btn-primary pull-right" type="submit" name="submit" value="Add Record">
</form>
<br/>
<br/>
</div>
</div>
<div class="col-lg-10 col-md-10 col-sm-2"></div>
</div>
</div>
<?php include("footer.php"); ?>
答案 0 :(得分:1)
您错过了价值$
$ query =“INSERT INTO管理(产品,成本,其他,其他,代码,价格,价值)VALUES('$ product','$ cost','$ other','$ otherOne','$ code ','$ price','$ qty','$ kg','$ value')“;