Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try {
- $base= new PDO("mysql:host=localhost; dbname=contador" , "root", "");
- $base->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $sql="SELECT * FROM usuarios WHERE ID=:id AND usuario = :usuario AND contra= :contra";
- //contador
- $contador = 0;
- //preparar consulta
- $resultado=$base->prepare($sql);
- //recivir parametros de el formulario
- $login= htmlentities(addslashes($_POST['usuario']));
- $password = htmlentities(addslashes($_POST['contra']));
- $ID=0;
- $resultado->bindValue(":usuario", $login);
- $resultado->bindValue(":contra", $password);
- $resultado->bindValue(":id", $ID);
- $resultado->execute(array(":id"=>$ID, ":contra"=>$password, ":usuario"=>$login));
- $registro=$resultado->fetch(PDO::FETCH_ASSOC);
- if (password_verify($password, $registro['contra'])) {
- $contador++;
- }
- $numero_registro=$resultado->rowCount();
- if ($numero_registro !=0 && $contador!=0){
- session_start();
- $_SESSION['usuario']=$_POST['usuario'];
- header("location: http://192.168.1.31/contador/");
- }else{
- header("location: index.php");
- }
- }catch(Exception $e) {
- die("Error: " . $e->getMessage());
- }
- <?php
- $host = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'contador';
- if (mysqli_connect_errno($conexion)) {
- echo 'Ha ocurrido un error al conectar a la base de datos';
- exit();
- }
- mysqli_set_charset($conexion, "utf8");
- $contra_has = "contrasena";
- $cifrada = password_hash($contra_has, PASSWORD_DEFAULT);
- if ($sql) {
- echo 'Se insertado correctamente';
- }else{
- echo 'Ha ocurrido un error';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement