mercredi 25 février 2015

How to update information into the database?

Im having a problem in updating the database,


This is my first page,





<div class="col-md-4">
<div class="createnewbox">
<form name="Edit Admin Infomation" class="form-horizontal" method="post" action="adminUpdateProductDetail.php?cat=<?php echo $product['categoryid']; ?>&code=<?php echo $product['productname']; ?>">
<h2>Edit Product Information</h2>
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>
<br/>
<br/>
<div class="col-md-11">
<input type="text" class="form-control" value="<?php echo $product['productname']; ?>" name="productname">
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">Price</label>
<br/>
<br/>
<div class="col-md-11">
<input type="text" class="form-control" value="<?php echo $product['price']; ?>" name="price">
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">Dimension</label>
<br/>
<br/>
<div class="col-md-11">
<input type="text" class="form-control" value="<?php echo $product['dimension']; ?>" name="dimension">
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">Description</label>
<br/>
<br/>
<div class="col-md-11">
<textarea type="text" class="form-control" rows="8" name="productinfo">
<?php echo $product[ 'productinfo']; ?>
</textarea>
</div>
</div>

<div class="form-group">
<div class="col-md-11">
<input type="submit" value="Update Information" class="btn btn-success">
<script>
function reset() {
location.reload();
}
</script>
<button class="btn btn-info" onclick="reset()">undo</button>
</div>
</div>
<?php ?>
</form>
</div>
</div>



This is my adminUpdateProductDetail.php,





<?php
include 'adminNavBar.php';
require 'dbfunction.php';

$con = getDbConnect();

$price = $_POST['price'];
$name = $_POST['productname'];
$info = $_POST['productinfo'];
$dimension = $_POST['dimension'];
$cat= $_GET['cat'];
$code= $_GET['code'];
?>
<div class="space">
<div class="container">
<div class="row">
<?php
if (!mysqli_connect_errno($con)) {
$sqlQueryStr = "UPDATE product SET price = '$price', productname = '$name', productinfo = '$info', dimension = '$dimension' WHERE categoryid = '$cat' AND productname = '$code'";
if (mysqli_query($con, $sqlQueryStr)) {
$recordid = mysqli_insert_id($con);




mysqli_query($con, $sqlQueryStr);
}
mysqli_close($con);
echo "$name Product details updated.";
} else {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
</div>
</div>
</div>



I gotten no error message, the system echo out success. But my database was not updated. I not sure where when wrong.


Aucun commentaire:

Enregistrer un commentaire