<!-- хлебные крошки --> <div class="breadcrumbs"> <a href="/">Магазин</a> <p>Создание товара</p> </div> <div class="row clearfix"> <?php use Respect\Validation\Validator as v; if (empty($_POST)) { include_once $src_path . "templates/_add-shop-item-form.php"; } else { include_once "/product_data-validate.php"; // Data Validation $errors = []; $title = titleValidate($errors, $_POST['title']); $description = descriptionValidate($errors, $_POST['description']); $price = priceValidate($errors, $_POST['price']); if ($_FILES['userfile']['error'] != 4) { $userfile = fileValidate($errors, $_FILES['userfile']['name']); } else { $userfile = false; } if (!v::arr()->notEmpty()->validate($errors)) { $category_id = $_POST['category']; $createProduct = new \App\DB\Products($connection, $title, $description, $price, $category_id); $id = \App\DB\Products::getCurrentId($connection); if ($userfile) { // Set new photo include_once "add-image.php"; } if ($createProduct) {
<?php session_start(); $array_data = array(); $descripcion = $_REQUEST['description-publication']; $lenguaje = $_REQUEST['language-publication']; $code = $_REQUEST['code-publication']; $array_data[] = descriptionValidate($descripcion); $array_data[] = languageValidate($lenguaje); $array_data[] = codeValidate($code); if ($array_data[0]["state"] === "Correcto" and $array_data[1]["state"] === "Correcto" and $array_data[2]["state"] === "Correcto") { if (isset($_SESSION["rowUser"])) { $rowUser = $_SESSION["rowUser"]; $strconn = "host=localhost port=5432 dbname=gitbook user=postgres password=12345"; $conn = pg_connect($strconn); $queryLeng = "SELECT idlenguaje FROM lenguajes WHERE lenguajes.nombre = '{$lenguaje}'"; $resultLen = pg_query($conn, $queryLeng); $row = pg_fetch_row($resultLen); $idLenguaje = $row[0]; if ($idLenguaje === null) { $query = "INSERT INTO lenguajes(nombre) values('{$lenguaje}')"; pg_query($conn, $query); $queryLeng = "SELECT idlenguaje FROM lenguajes WHERE lenguajes.nombre = '{$lenguaje}'"; $resultLen = pg_query($conn, $queryLeng); $row = pg_fetch_row($resultLen); $idLenguaje = $row[0]; } $query = "INSERT INTO publicaciones(idpersona,descripcion,idlenguaje,codigo)"; $code = $_REQUEST['code-publication']; $query .= " values('{$rowUser['0']}','{$descripcion}',{$idLenguaje},'{$code}')"; $result = pg_query($conn, $query);