is to log in to an admin panel in a web app
Notice: Undefined index: RESQUEST_METHOD in C: \ xampp \ htdocs \ groups \ proyectpudines jhon, erbin , jordy \ login.php on line 4
<?php
// archivo del admin
require 'config.php';
require '../functions.php';
$conexion = conexion($bd_config);
// comprobar session
if (!$conexion){
header ('location: ../error.php');
}
$posts = obtener_post ($blog_config['post_por_pagina'], $conexion);
require '../views/admin_index.view.php';
?>
< - config file - >
<?php
define('RUTA', 'http://localhost/grupos/proyectpudines jhon , erbin ,, jordy');
$bd_config = array(
'basedatos' => 'amiscake',
'usuario' => 'root',
'pass' => ''
);
$blog_config = array(
'post_por_pagina' => '8',
'carpeta_imagenes' => 'imagenes/'
);
$blog_admin = array(
'usuario' => 'jhon',
'password' => '123'
);
?>
< - functions file - >
<?php
// CONEXION A LA BASE DE DATOS
function conexion($bd_config){
try {
$conexion = new PDO('mysql:host=localhost;dbname='.$bd_config['basedatos'], $bd_config['usuario'], $bd_config['pass']);
return $conexion;
} catch (PDOException $e) {
return false;
}
}
// FUNCION PARA QUE EL USUARIO NO ME INYECTE CODIGO
function limpiardatos($datos){
$datos = trim($datos);
$datos = stripcslashes($datos);
$datos = htmlspecialchars($datos);
return $datos;
}
// FUNCION PARA MOSTRAR POR PAGINA
function pagina_actual(){
return isset($_GET['p']) ? (int)$_GET['p'] : 1;
}
// LA FUNCION QUE ME OBTIENE LOS POST DE LA BASE DE DATOS
function obtener_post($post_por_pagina, $conexion){
$inicio = (pagina_actual() > 1 ) ? pagina_actual() * $post_por_pagina - $post_por_pagina: 0;
$sentencia = $conexion->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM articulosamiscake LIMIT $inicio, $post_por_pagina ");
$sentencia->execute();
return $sentencia->fetchAll();
}
function numero_paginas($post_por_pagina, $conexion){
$total_post = $conexion->prepare('SELECT FOUND_ROWS() as total ');
$total_post->execute();
$total_post = $total_post->fetch()['total'];
$numero_paginas = ceil($total_post / $post_por_pagina);
return $numero_paginas;
}
function id_articulo($id){
return (int)limpiardatos($id);
}
function obtener_post_por_id($conexion, $id){
$resultado = $conexion->query("SELECT * FROM articulosamiscake WHERE id = $id LIMIT 1");
$resultado = $resultado->fetchAll();
return($resultado) ? $resultado : false;
}
function fecha ($fecha){
$timestamp = strtotime($fecha);
$meses = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
$dia = date('d', $timestamp);
$mes = date('m', $timestamp) - 1;
$year = date('Y', $timestamp);
$fecha = " $dia " . $meses[$mes] ." $year";
return $fecha;
}
?>