I want to insert image into my database table. I have search google but I can not insert image into my database. My database field name is 'photo' and data type is 'blob'. please help...
here is my code:
<?php
$id="";
$opr="";
if(isset($_GET['opr']))
$opr=$_GET['opr'];
if(isset($_GET['rs_id']))
$id=$_GET['rs_id'];
//--------------add data-----------------
if(isset($_POST['btn_sub'])){
$fac_name=$_POST['factxt'];
$batch=$_POST['batchtxt'];
$reg=$_POST['regtxt'];
$s_name=$_POST['snametxt'];
$f_name=$_POST['fnametxt'];
$gender=$_POST['gender']
$phone=$_POST['phonetxt'];
$mail=$_POST['emailtxt'];
$photo=$_POST['photos'];
$sql_ins=mysql_query("INSERT INTO stu_tbl
VALUES(
NULL,
'$fac_name',
'$batch',
'$reg',
'$s_name',
'$f_name' ,
'$gender',
'$phone',
'$mail',
'$photo'
)
");
if($sql_ins==true)
$msg="1 Row Inserted";
else
$msg="Insert Error:".mysql_error();
}
?>
<!DOCTYPE html>
<head>
</head>
<body>
<h2 class="custom-light-heading" align="center">Add New Student</h2>
<hr>
<form method="post">
<table>
<tr>
<td>Faculties's Name</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>Batch:</td>
<td>
<input type="text" class="form-control" name="batchtxt" id="textbox" />
</td>
</tr>
<tr>
<td>Registration:</td>
<td>
<input type="text" class="form-control" name="regtxt" id="textbox" />
</td>
</tr>
<tr>
<td>Student Name:</td>
<td>
<input type="text" class="form-control" name="snametxt" id="textbox" />
</td>
</tr>
<tr>
<td>Father's Name:</td>
<td>
<input type="text" class="form-control" name="fnametxt" id="textbox" />
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender" value="Male" checked="checked" />Male
<input type="radio" name="gender" value="Female" />Female
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input type="text" class="form-control" name="phonetxt" id="textbox" />
</td>
</tr>
<tr>
<td>E-mail:</td>
<td>
<input type="text" class="form-control" name="emailtxt" id="textbox" />
</td>
</tr>
<tr>
<td>photo:</td>
<td>
<input type="File" name="photos" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="btn_sub" class="btn btn-success" value="Add" id="button-in" />
</td>
</tr>
</table>
</div>
</form>
</div>
<?php ?>
</body>
</html>