-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistro.php
More file actions
87 lines (57 loc) · 1.95 KB
/
Copy pathregistro.php
File metadata and controls
87 lines (57 loc) · 1.95 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require 'database.php';
$message = '';
if (!empty($_POST['nombre']) && !empty($_POST['apellido']) && !empty($_POST['dni'])) {
$conf_pass = $_POST['conf_pass'];
$pass = $_POST['pass'];
$dni = $_POST['dni'];
$email = $_POST['email'];
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$sql_dni = "SELECT * FROM clientes WHERE dni='$dni'";
$res_dni = mysqli_query($fra31, $sql_dni);
if (mysqli_num_rows($res_dni) > 0) {
echo 'Este DNI ya esta registrado.';
}else{
if ($pass == $conf_pass) {
$sql = "INSERT INTO clientes (dni, nombre, apellido, pass, email) VALUES (:dni, :nombre, :apellido, :pass, :email)";
$stmt = $fra30->prepare($sql);
$stmt->bindParam(':dni', $_POST['dni']);
$stmt->bindParam(':nombre', $_POST['nombre']);
$stmt->bindParam(':apellido', $_POST['apellido']);
$pass = password_hash($_POST['pass'], PASSWORD_BCRYPT);
$stmt->bindParam(':pass', $pass);
$stmt->bindParam(':email', $_POST['email']);
if($stmt->execute()){
$message = 'Registrado con éxito';
}else{
$message = 'Error del servidor, inténtelo de nuevo mas tarde.';
}
}else {
echo 'Las contraseñas no coinciden';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Registro</title>
</head>
<body>
<?php require 'partes/header.php' ?>
<?php if(!empty($message)): ?>
<p> <?= $message ?></p>
<?php endif; ?>
<form action="registro.php" method="POST">
<input name="nombre" type="text" placeholder="Ingrese su Nombre" required>
<input name="apellido" type="text" placeholder="Ingrese su Apellido" required>
<input name="dni" type="number" min="0" step="1" placeholder="Ingrese su DNI" maxlength="13" required>
<input name="pass" type="password" placeholder="Crea una Contraseña" required>
<input name="conf_pass" type="password" placeholder="Confirmar Contraseña" required>
<input name="email" type="text" placeholder="Ingrese su email">
<input type="submit" value="Enviar">
</form>
</body>
</html>