forked from pacohunterdev/ventas-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiniciar_sesion.php
More file actions
36 lines (29 loc) · 896 Bytes
/
iniciar_sesion.php
File metadata and controls
36 lines (29 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include_once "encabezado.php";
if(isset($_POST['ingresar'])){
if(empty($_POST['usuario']) || empty($_POST['password'])){
echo'
<div class="alert alert-warning mt-3" role="alert">
Debes completar todos los datos.
<a href="login.php">Regresar</a>
</div>';
return;
}
include_once "funciones.php";
$usuario = $_POST['usuario'];
$password = $_POST['password'];
session_start();
$datosSesion = iniciarSesion($usuario, $password);
if(!$datosSesion){
echo'
<div class="alert alert-danger mt-3" role="alert">
Nombre de usuario y/o contraseña incorrectas.
<a href="login.php">Regresar</a>
</div>';
return;
}
$_SESSION['usuario'] = $datosSesion->usuario;
$_SESSION['idUsuario'] = $datosSesion->id;
header("location: index.php");
}
?>