Здравствуйте, при каждом обновлении странице добавляется картинка в дб, как этого избежать?
function GoCard(){
$uploads_dir = __DIR__ . '/images/';
$tmp_name = $_FILES["pictures"]["tmp_name"];
$name = $_FILES["pictures"]["name"];
$path = '/libraries/images/' . $name;
move_uploaded_file($tmp_name, "$uploads_dir/$name");
mysql_query("INSERT INTO people (name) VALUES ('$path')");
}
GoCard();
function ReadFromBD(){
$res = mysql_query("SELECT * FROM people");
$mass = array();
while (false !==($row = mysql_fetch_array($res))){
$mass[] = $row['name'];
}
return $mass;
}
function GetCard(){
foreach(ReadFromBD() as $key => $value){
echo "<img src='$value'/>";
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div>
<h1>Привет, <?php echo getUser() ?></h1>
<span><?php GetCard() ?></span><br>
<span><?php catalogy() ?></span><br>
<div>
<form action="/libraries/index.php" method="post" enctype="multipart/form-data">
<input type="file" name="pictures">
<input type="submit">
</form>
</div>
<a href="/libraries/logout.php">выход</a>
</div>
</body>
</html>