function edit_post($connect, $post_id){
$post_id = $_GET['post_id'];
if(isset($_POST['submit'])){
$title = $_POST['title'];
$text = $_POST['text'];
$category = $_POST['category'];
$update = "UPDATE posts SET `title` = '$title', `text` = '$text', `category_id` = '$category' WHERE id = ".$post_id;
$result = mysqli_query($connect, $update);
header("Location: ". $_SERVER["REQUEST_URI"]);
}
}
if($_SERVER['REQUEST_METHOD'] == 'POST'){
//Перемещение файла в специальную директорию
if(move_uploaded_file($_FILES['image']['tmp_name'], $path . $_FILES['image']['name'])){
$image = ($_FILES['image']['name']);
$sql = "INSERT INTO posts (`image`) VALUES ('$image')";
mysql_query($connect, $sql);
}