-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysqlejercicio1.php
More file actions
45 lines (35 loc) · 1.23 KB
/
mysqlejercicio1.php
File metadata and controls
45 lines (35 loc) · 1.23 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
<?php
$conexion = new mysqli("localhost", "root","ausias", "neptuno");
if ($conexion->connect_errno) {
die( "Fallo al conectar a MySQL: (" . $conexion->connect_errno . ") " . $conexion->connect_error);
}
$usuario = $conexion->real_escape_string($_POST['usuario']);
$pass = $conexion->real_escape_string($_POST['pass']);
$sql = <<< SQL
SELECT *
from cliente
where codCliente='$usuario' and pass=md5('$pass')
SQL;
$resultado = new mysqli_result();
$validado=false;
if ($resultado = $conexion->query($sql) and $resultado->num_rows==1) {
while ($fila = $resultado->fetch_array()){
$validado=true;
$id=$fila["idCliente"];
$cliente=$fila["nombreCli"];
$telefono=$fila["telefono"];
}
$resultado->free();
}
if ($validado==false){
die ("Login incorrecto");
};
$conexion->close();
?>
<form action="edita.php" method="post">
Actualice su información de cliente<br>
Nombre de cliente: <input type="text" name="cliente" value="<?php echo $cliente;?>"><br>
Telefono: <input type="text" name="telefono" value="<?php echo $telefono;?>"><br>
<input type="hidden" name="id" value="<?php echo $id;?>">
<input type="submit">
</form>