I have created a form for the admin of my website through which he can enter new stock into the mysql table laptops, the form has 6 fields 1. Modelno 2. CPU 3. RAM 4. HDD 5. Display 6. Upload
When the file is being uploaded its going to the assigned directory which is like half the battle one, the table laptop has a field pic of type BLOB, how do I insert data into that field?
the html code for form is as follows:
<html>
<head>
</head>
<body>
<form action="stockm.php" method="post">
<table cellspacing="10">
<tr>
<td>
Model No:
</td>
<td>
<input type="text" name="fname">
</td>
</tr>
<tr>
<td>
C.P.U:
</td>
<td>
<input type="text" name="fcpu">
</td>
</tr>
<tr>
<td>
RAM:
</td>
<td>
<input type="text" name="fram">
</td>
</tr>
<td>
HDD:
</td>
<td>
<input type="text" name="fhdd">
</td>
</tr>
<td>
Display:
</td>
<td>
<input type="text" name="fdisplay">
</td>
</tr>
<tr>
<td>
Upload:
</td>
<td>
<input type="file" name="file" id="file"><br>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="fsubmit" value="Deposit">
</table>
</form>
</body>
</html>
and the code for data entry is this, please tell me what I need to add?
<html>
<head>
</head>
<body>
<?php
$con=mysqli_connect("localhost","****","******","stock");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO Laptops (Modelno, Cpu, RAM, HDD, Display)
VALUES
('$_POST[fname]','$_POST[fcpu]','$_POST[fram]','$_POST[fhdd]','$_POST[fdisplay]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
</body>
</html>
Thank You in advance