Created
September 29, 2020 13:17
-
-
Save jorgecc/b3c71a5b8a5abbe91fffd342c9884460 to your computer and use it in GitHub Desktop.
login.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// requiere composer https://getcomposer.org/ | |
// requiere instalar la libreria pdoone dentro de composer https://github.com/EFTEC/PdoOne | |
use eftec\PdoOne; | |
include __DIR__.'/vendor/autoload.php' | |
try { | |
$conn=new PdoOne('mysql','localhost','login_tutor','root',''); | |
} catch(Exception $ex) { | |
echo $ex->getMessage(); | |
die(1); | |
} | |
$usuario['usuario']=$_POST['usuario']; | |
$usuario['clave']=hash('sha512',$_POST['clave']); | |
$usuarioBase=$conn->select('*')->from('login')->where($usuario)->first(); | |
if($usuarioBase!==false) { | |
@session_start(); | |
$_SESSION['usuario']=$usuarioBase; | |
header('location:principal.php'); | |
die(1); | |
} else { | |
echo "usuario no existe o clave incorrecta"; | |
} | |
include "login-vista.php"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment