PDA

View Full Version : Profile Picture Upload Problem


Tiger
03-11-2016, 01:00 AM
Hey, I'm using this script, It work's if i replace "['Username']" with my username manually, how can i get it to auto echo the username that's logged in? Thanks :)

<?php session_start();
$_SESSION['Username'] = "['Username'];"
?>

<?php
if(isset($_POST['submit'])){
move_uploaded_file($_FILES['file']['tmp_name'],"pictures/".$_FILES['file']['name']);
$con = mysqli_connect("localhost","*******","******","******");
$q = mysqli_query($con,"UPDATE user_db SET pic = '".$_FILES['file']['name']."' WHERE Username = '".$_SESSION['Username']."'");
}
?>

<!DOCTYPE html>
<html>
<head>

</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="submit">
</form>

edbr
03-12-2016, 04:08 AM
Rename the file when you upload it