public function delComment($id) { $connect = new DB_Connection(); $mysqli = $connect->getConnect(); $mysqli->query("DELETE FROM comments WHERE id = " . $id) or die("Cannot delete comment"); header('Location: . '); }
public function delRecord($id) { $connect = new DB_Connection(); $mysqli = $connect->getConnect(); $mysqli->query("DELETE FROM records WHERE id = " . $id) or die("Cannot delete record"); $mysqli->query("DELETE FROM comments WHERE record_id = " . $id) or die("Cannot delete comment"); header("Location: . "); }
public function getNewsOneAuthor($action) { $mysqli = new DB_Connection(); $result = $mysqli->getConnect()->query('SELECT news.*, authors.name FROM news, authors WHERE news.author_id = authors.id AND authors.id = ' . $action); $news = array(); while ($row = $result->fetch_assoc()) { if (mb_strlen($row['text']) > 100) { $row['text'] = mb_substr(strip_tags($row['text']), 0, 97) . '...'; } $news[] = $row; $name = $row['name']; } include ROOT . '/pages/list_one_author.php'; }
$image_new = imagecreatetruecolor(100, 100); //create a new image in jpeg format $image = imagecreatefromjpeg($avatar_tmp); //copy an avatar in the new picture, size decreases imagecopyresampled($image_new, $image, 0, 0, 0, 0, 100, 100, $img_width, $img_height); //save image in file - temp_image.jpeg imagejpeg($image_new, "temp_image.jpeg", 100); //new length and height of the image list($new_img_width, $new_img_height) = getimagesize("temp_image.jpeg"); //array with new parameters of image $temp_image = getimagesize("temp_image.jpeg"); //get image $img_data = file_get_contents("temp_image.jpeg"); require_once './DB_connection/DB_connect.php'; $mysqli = new DB_Connection(); $sql = $mysqli->getConnect(); if (!($stmt = $sql->prepare("INSERT INTO registration (name, surname, patronymic, login, password )\r\n VALUES (?, ?, ?, ?, ?)"))) { echo "Prepare failed: (" . $sql->errno . ") " . $mysqli->error; } if (!$stmt->bind_param('sssss', $name, $surname, $patronymic, $login, $password)) { echo "Binding output parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } //id of last INSERT $id = mysqli_insert_id($sql); if (!($stmt = $sql->prepare("INSERT INTO avatar (avatar_mime, avatar_size, avatar_date, user_id)\r\n VALUES (?, ?, ?, ?)"))) { echo "Prepare failed: (" . $sql->errno . ") " . $sql->error; } if (!$stmt->bind_param('sssi', $temp_image['mime'], $temp_image['bits'], $img_data, $id)) {
<?php /** * check login in data base from function ifLoginAjax */ $login = htmlspecialchars($_POST['login']); $login = "******" . $login . "'"; require_once './DB_connection/DB_connect.php'; $mysqli = new DB_Connection(); $name = $mysqli->getConnect()->query("SELECT COUNT(login) AS count\r\n FROM registration WHERE login LIKE " . $login)->fetch_assoc(); if ($name['count'] >= 1) { echo "This login is not available"; } else { echo "Ok"; }
<?php // output information $id = $_GET['id']; require_once './DB_connection/DB_connect.php'; $mysqli = new DB_Connection(); $result = $mysqli->getConnect()->query("SELECT * FROM registration WHERE id = " . $id)->fetch_assoc(); include './info.php';
<?php /** * output avatar */ $id = $_REQUEST['id']; require_once './DB_connection/DB_connect.php'; $mysqli = new DB_Connection(); $avatar = $mysqli->getConnect()->query("SELECT * FROM avatar WHERE user_id = " . $id)->fetch_assoc(); header('Content-type: ' . $avatar['avatar_mime']); header('Content-type: ' . $avatar['avatar_size']); echo $avatar['avatar_date'];