I want to upload images to a database where the image will only echo out if it is by the user but it doesn't work and it doesn't give me any errors
<?php
session_start();
$pic = $_FILES['pic'];
$submit = $_POST['post'];
$user = $_SESSION['username'];
if($submit){
$connect = mysql_connect("localhost", "root", "123");
if($connect){
$database = mysql_select_db("phplogin");
if($database){
mysql_query("INSERT INTO images(image, user) VALUES ($pic, $user)");
$query = mysql_query("SELECT * FROM images WHERE user = '$user'");
$data2 = mysql_fetch_array($query);
header("Content-type: image/jpeg");
echo $data2['image'];
} else {
die("Couldn't connect to the database please try again, if you fail to connect again please contact me");
}
} else {
die("Couldn't connect to the database please try again, if you fail to connect again please contact me");
}
}
?>