Mysql Database attribute image name and type
`Image varchar256`
I m trying to upload image name in mysql but issue is image is move to folder as per requirement but name of image is not showing in database. kindly help...
<form method="post" enctype="multipart/form-data" >
<div class="content table-responsive table-full-width">
<div class="title" style="margin-left: 7%;"> Product ID</div>
<input class="form-control" type="text" name="P_id" placeholder="Product ID" readonly/>
<div class="title" style="margin-left: 7%;" >Product Name</div>
<input class="form-control" type="text" name="P_Name" placeholder="Product Name" required/>
<div class="title" style="margin-left: 7%;">Descriptiom</div>
<textarea class="form-control" type="text" name="P_Description" placeholder="Description"required></textarea>
<div class="title" style="margin-left: 7%;">Category</div>
<!-- Category Add in Drop Down-->
<select name="C_id" class="form-control" required>
<option>Select Category</option>
<?php
$get_category= "select * from category";
$run_category= mysqli_query($con,$get_category);
while($row_category=mysqli_fetch_array($run_category))
{
$C_id=$row_category['C_id'];
$C_Name=$row_category['C_Name'];
echo "<option value='$C_id'>$C_Name</option>";
}
?>
</select><!-- End Conde-->
<div class="title" style="margin-left: 7%;">Price</div>
<input class="form-control" type="text" name="P_Price" placeholder="Enter Price"required/>
<div class="title" style="margin-left: 7%;">Quantity</div>
<input class="form-control" type="text" name="P_Quantity" placeholder="Enter Quantity"required/>
<div class="title" style="margin-left: 7%;">Image</div>
<input class="form-control" type="file" name="image" placeholder="Upload Image"required accept=""/>
<div class="navbar-form">
<input type="submit" class="btn btn-primary " name="Insert" value="Insert"style="margin-left: 7%;"/>
<label name="Label" ></label>
</div>
<div class="navbar-form">
<a href="Categoryadd.php" class="btn btn-primary"style="margin-left: 7%;">+Add Category</a>
<a href="Brands.php" class="btn btn-primary">+Add Brand</a>
</div>
</div>
</form>
The Example which move image to folder but image name not showing in database
<?php
if(isset($_POST['Insert'])){
$P_id=$_POST['P_id'];
$P_Name=$_POST['P_Name'];
$P_Description= $_POST['P_Description'];
$CId=$_POST['C_id'];
$P_Price=$_POST['P_Price'];
$P_Quantity=$_POST['P_Quantity'];
//image names
$PImage = $_FILES['image']['name'];
//image temp names
$tempname = $_FILES["image"]["tmp_name"];
//for image upload on folder
move_uploaded_file($tempname,"Images/$PImage");
if($PName='' OR $PDescription='' OR $C_id='' OR $Price='' OR $Quantity='' OR $PImage='' )
{
echo"<script>alert('please fill fields')</script>";
}
else {
$insert_Product = "INSERT INTO `product`(`P_id`, `P_Name`, `P_Description`, `Price`, `Quantity`, `C_Id`, `Image`) VALUES ('','$P_Name','$P_Description','$P_Price','$P_Quantity','$CId','$PImage')";
$run_Product = mysqli_query($con, $insert_Product);
if($run_Product){
$label= "Label";
$label= "Enter Data successfully";
echo $label;
}
}
}
?>
How can i resolve my issue ?