Here is my code:
I splitted it up so it will echo out the image with the first script and echo out the users image in the second script
<?php $username = isset($_SESSION['username']); $query = mysql_query("SELECT * FROM `users` WHERE `username`='$username'"); if (mysql_num_rows($query)==0) die("User not found!"); else { $row = mysql_fetch_array($query); $location = $row['profile']; echo "<img src='$location'>"; } ?> <?php isset($_SESSION['username']); $username = $_SESSION['username']; if (isset($_POST['submit'])) { $name = $_FILES['myfile']['name']; $tmp_name = $_FILES['myfile']['tmp_name']; if ($name) { $location = "images/$name"; move_uploaded_file($tmp_name,"images/profile/".$name); $query = mysql_query("UPDATE `users` SET profile='$location' WHERE `username`='$username'"); die("Your images have been has been uploaded!"); } else die("Please select a file!"); } echo "Upload your image: <div class='profile'> <form action='' method='post' enctype='multipart/form-data'> File: <input type='file' name='myfile'> <input type='submit' name='submit' value='Upload!'> </form> </div> "; ?>