So i'm working on a project where i have to upload something to a database. In my case i upload pictures. Now the problem is, if i upload a picture and refresh the page the picture gets uploaded again. If i upload 3 pictures then the last picture gets uploaded again and again every time i refresh the page.
?php
if (isset($_POST['upload'])){
$target = "images/".basename($_FILES['image']['name']);
$db = mysqli_connect("localhost", "root", "", "aawebprog");
$image = $_FILES['image']['name'];
$text = $_POST['text'];
$uploader = $_SESSION['username'];
if($text > 50){
$msg = "You have to write at least 50 characters!";
}
$sql = "INSERT INTO pictures (image, text, uploader) VALUES ('$image', '$text', '$uploader')";
mysqli_query($db,$sql);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)){
$msg = "Image upluaded succesfully";
} else{
$msg = "There was a problem during the upload, try again";
}
echo ("$msg");
}
?
Any ideas what can be the problem?