35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
require_once __DIR__.'/auth_guard.php';
|
|
require_once __DIR__.'/audit.php';
|
|
|
|
require_once "../config.php";
|
|
|
|
$urlimgcat = isset($_POST['urlimgcat']) ? $_POST['urlimgcat'] : '';
|
|
$nombre = isset($_POST['nombre']) ? $_POST['nombre'] : '';
|
|
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
|
|
$habilitado = isset($_POST['habilitado']) ? (int)$_POST['habilitado'] : 0;
|
|
$order = isset($_POST['order']) ? (int)$_POST['order'] : 0;
|
|
$clave = isset($_POST['clave']) ? $_POST['clave'] : '';
|
|
$catsuperior = isset($_POST['catsuperior']) ? (int)$_POST['catsuperior'] : 0;
|
|
|
|
global $link;
|
|
dbConnect();
|
|
|
|
$sql = "INSERT INTO categoria (padre,imagen,nombre,descripcion,habilitado,order_desc,clave) VALUES (?,?,?,?,?,?,?)";
|
|
$stmt = mysqli_prepare($link, $sql);
|
|
if ($stmt) {
|
|
mysqli_stmt_bind_param($stmt, 'issssis', $catsuperior, $urlimgcat, $nombre, $desc, $habilitado, $order, $clave);
|
|
if (mysqli_stmt_execute($stmt)) {
|
|
audit_log('categoria_create', 'nombre=' . $nombre . ' padre=' . $catsuperior);
|
|
echo "Categoría creada";
|
|
} else {
|
|
http_response_code(500);
|
|
echo "Error al crear categoría";
|
|
}
|
|
mysqli_stmt_close($stmt);
|
|
} else {
|
|
http_response_code(500);
|
|
echo "Error al preparar la consulta";
|
|
}
|
|
?>
|