Skip to content

Instantly share code, notes, and snippets.

@jorgecc
Created September 29, 2020 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgecc/b3c71a5b8a5abbe91fffd342c9884460 to your computer and use it in GitHub Desktop.
Save jorgecc/b3c71a5b8a5abbe91fffd342c9884460 to your computer and use it in GitHub Desktop.
login.php
<?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