49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
require_once __DIR__.'/auth_guard.php';
|
||
|
|
error_reporting(0);
|
||
|
|
require_once "../config.php";
|
||
|
|
|
||
|
|
$catsuperior = $_POST['catsuperior'];
|
||
|
|
$titulo= $_POST['titulo'];
|
||
|
|
$desc= $_POST['desc'];
|
||
|
|
$orden= $_POST['orden'];
|
||
|
|
$estilo= $_POST['estilo'];
|
||
|
|
$habilitado= $_POST['habilitado'];
|
||
|
|
if( $_POST['urlimgencuesta'] == "" ){
|
||
|
|
$urlimgencuesta = $CFG->wwwroot.'img/icons/211-gift.png';
|
||
|
|
}else{
|
||
|
|
$urlimgencuesta =$_POST['urlimgencuesta'];
|
||
|
|
}
|
||
|
|
|
||
|
|
global $link;
|
||
|
|
dbConnect();
|
||
|
|
$return = new stdClass();
|
||
|
|
|
||
|
|
$sql = "INSERT INTO encuestas (idcategoria, titulo, descripcion, order_desc, estilo, habilitado, imagen) VALUES ($catsuperior,'$titulo', '$desc', $orden, '$estilo', $habilitado,'$urlimgencuesta');";
|
||
|
|
$sql .= " SELECT LAST_INSERT_ID() as id;";
|
||
|
|
|
||
|
|
if($result = mysqli_multi_query($link, $sql)){
|
||
|
|
$return->code = "200";
|
||
|
|
do {
|
||
|
|
/* almacenar resultado de la primera consulta */
|
||
|
|
if ($result = mysqli_store_result($link)) {
|
||
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
||
|
|
$return->data = $row;
|
||
|
|
|
||
|
|
}
|
||
|
|
mysqli_free_result($result);
|
||
|
|
}
|
||
|
|
/* mostrar divisor */
|
||
|
|
if (mysqli_more_results($link)) {
|
||
|
|
//printf("-----------------\n");
|
||
|
|
}
|
||
|
|
} while (mysqli_next_result($link));
|
||
|
|
|
||
|
|
}else{
|
||
|
|
$return->code = "400";
|
||
|
|
$return->msg = "Consulta fallo! SQL: ".$sql."<br><br> Error: ".mysqli_error($link);
|
||
|
|
}
|
||
|
|
|
||
|
|
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||
|
|
exit;
|
||
|
|
?>
|