i am learning php and am working on a form that will insert registration details together with a file to mysql database the details are inserted but i can't get the file part right here is my db table and code;
how to registration details and a file into mysql database
db table
create table std
(
stdid int,
typeofwork varchar (50) not null,
fieldofstudy varchar (50) not null,
topic varchar (50) not null,
academiclevel varchar (50) not null,
formating varchar (50) not null,
material BLOB,
materialname varchar (100) not null,
email varchar (30) not null,
);
HTML
<form method="post" action=" " enctype="multipart/form-data">
Type of work :<select id="typeofwork" name="typeofwork" required/>
<option value="Essay writing">Essay writing</option>
<option value="Terms Papers">Terms Papers</option>
</select><br>
Field of study: <select id="fieldofstudy" name="fieldofstudy" />
<option value="History">History</option>
<option value="Philosophy">Philosophy</option>
</select><br>
Topic :<input placeholder="Enter the topic" id="topic" type="text" name="topic" /><br>
<select id="academiclevel" name="academiclevel" />
<option value="High School">High School</option>
<option value="Undergraduate">Undergraduate</option>
<option value="Master">Master</option>
<option value="PHD">PHD</option>
</select><br>
Format: <select id="formating" name="formating" />
<option value="APA">APA</option>
<option value="Harvard">Harvard</option>
</select><br>
Upload :<input type="file" id="material" name="material" /><br>
Email :<input placeholder="Email" id="email" type="text" name="email" /><br>
<input type="submit" name="submit" value="submit">
</form>
php
if(isset($_POST['submit'])){
try{
$conn=new PDO($con,$username,$password);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$material=addslashes($_FILES['material']['tmp_name']);
$materialname=addslashes($_FILES['material']['name']);
$material=file_get_contents($material);
$sql="INSERT INTO std_t(typeofwork,fieldofstudy,academiclevel,topic,formating,email)
VALUES ('$_POST[typeofwork]','$_POST[fieldofstudy]','$_POST[academiclevel]','$_POST[topic]','$material','$_POST[email]')";
$conn->exec($sql);
{echo '<b>Order made Successfully</b></p></center>';}
}
catch(PDOException $e)
{
echo $sql."<br/>".$e->getMessage();
}
}
$conn=null;
?>