Member Avatar for andyshady

Hello Everyone,

I am having a very basic problem in PHP MYSQL. My requirement is to add images in MYSQL through PHP along with the username. I have managed to store images in MYSQL but I dont know how to store username along with that image uploading query. Just like facebook where you upload images and they go into facebook database along with your username. Here is the basic query I am writing. Any help would be greatly appreciated.

<?php
$uploaddir = './images/';
$file = $uploaddir.basename($_FILES);
$file_name=$_FILES;
$username=$_FILES;

if (move_uploaded_file($_FILES, $file)) {
require_once("connection.php");

$sql=mysql_query("INSERT INTO `picture` (`id`, `date`, `ip`, `filename`, `username`) VALUES ('', '".date('d-m-Y')."', '".$_SERVER['REMOTE_ADDR


?>

Thank You

Well if you can succesfully upload the image, just use the session username for the value.

<?php
$username = $_SESSION['username']; 
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.