0

The connection is correct fields are set correctly but can't locate the problem from the code.After an hour ago it was work fine but after putting more fields it goes stuck.Form submitting correctly but the fields in xampp have nothing.Please help me to submit data.See the variables below, in fact, all the code below.

 <?php 
  $product = "";
  $cost = "";
  $other = "";
  $otherOne = "";
  $code = "";
  $price = "";
  $qty  = "";
  $kg   = "";
  $value = "";
  $id = 0;

Here is my config.php file code and its connect properly with my database as it cant show any die() error.

<?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>");

?>

//When Form Submits

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"); ?>

1 Answers1

1

You are missing the $ from value

$query = "INSERT INTO managment(product, cost, other, otherOne, code, price, value) VALUES ('$product','$cost','$other', '$otherOne', '$code', '$price', '$qty', '$kg', '$value')";

Em Jay
  • 63
  • 7