При отправке запроса возвращает false (4 строка снизу где запрос на удаление)
<?php
session_start();
$main = new MainClass();
$host = 'localhost';
$user = 'u91108o2_db';
$db = 'u91108o2_db';
$pass = 'roooot';
$main->connect = new PDO("mysql:host=$host;dbname=$db",$user,$pass);
class MainClass {
function db_e($sql){
$result = $this->connect->exec($sql);
return $result;
}
function db_q ($sql)
{
$result = $this->connect->query($sql);
return $result;
}
function get_posts(){
$result = $this->db_q("SELECT * FROM `table` ORDER BY `post_id` DESC");
$res = "";
foreach ($result as $row)
{
$res .= "
<div class='post'>
<h1>".$row["post_name"]."</h1>
<input onclick='delete_post(this)' class='del_button hide' type='button' id='".$row["post_id"]."' value='Удалить'>
<img width=\"100\" src='img/".$row["post_img"]."'>
<p>".$row["post_text"]."</p>
</div>
<hr />
";
}
return $res;
}
function create_post()
{
if (empty($_SESSION['login']))
{
return;
}
else if ($_SESSION['login'] != true)
{
return;
}
$post_name = $_POST['name'];
$check_name = $this->db_q("SELECT * FROM `table`");
foreach ($check_name as $name)
{
if ($name['post_name'] == $post_name)
{
return false;
}
}
$post_text = $_POST['text'];
$name = explode(".", $_FILES['img']['name']);
$img_type = $name[count($name) - 1];
$new_image_path = "../img/".md5($_POST['name'].$_FILES['img']['name']).".".$img_type;
if (!move_uploaded_file($_FILES['img']['tmp_name'], $new_image_path))
{
die;
}
else
{
$img = md5($_POST['name'].$_FILES['img']['name']).".".$img_type;
if ($this->db_e("INSERT INTO `table`(`post_name`, `post_text`, `post_img`) VALUES ('$post_name','$post_text','$img')"))
{
echo "success";
}
}
}
function login()
{
$_SESSION['login'] = false;
$users = $this->db_q("SELECT * FROM `user`");
foreach ($users as $user) {
if ($user['nick'] == $_POST['login']) {
if ($user['hash'] == md5($_POST['pass'])) {
$_SESSION['login'] = true;
break;
}
}
}
return $_SESSION['login'];
}
}
####################################################################
####################################################################
######################## Вызов принят XD ###########################
####################################################################
####################################################################
if (isset($_POST['get_posts']))
{
echo $main->get_posts();
}
if (isset($_POST["create"]))
{
if (!empty($_POST['name']) && !empty($_POST['text']) && !empty($_FILES))
{
$main->create_post();
}
}
if (isset($_POST['auth']))
{
if (!empty($_POST['login']) && !empty($_POST['pass']))
{
echo $main->login();
}
}
if (isset($_POST['delete']))
{
// echo "success";
//if (
$id = $_POST["id"];
$id *= 1;
var_dump($main->db_e("DELETE * FROM `table` WHERE `post_id` = $id"));//)
//{
echo "success";
//}
}