-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperfil.php
142 lines (120 loc) · 5.54 KB
/
perfil.php
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
session_start();
require_once("gestionBD.php");
require_once("gestionJugadores.php");
require_once("gestionarUsuarios.php");
if(isset($_SESSION['login'])){
$nickUsuario = $_SESSION['login'];
}else{
Header("Location: login.php");
}
$conexion = crearConexionBD();
$dniUsuario = obtenDniUsuarioR($conexion, $nickUsuario);
$dniUser = $dniUsuario["DNIUSUARIO"];
$mailUsuario=obtenEmailUsuario($conexion, $nickUsuario);
$mailUser = $mailUsuario["EMAILUSUARIO"];
$nameUsuario= obtenNombreUsuario($conexion, $nickUsuario);
$nameUser=$nameUsuario["NOMBRECOMPLETOUSUARIO"];
$numUsuario=obtenNumeroUsuario($conexion, $nickUsuario);
$numUser=$numUsuario["NUMTELEFONOUSUARIO"];
$passUsuario=obtenPassUsuario($conexion, $nickUsuario);
$passUser=$passUsuario["PASSUSUARIO"];
if(isset($_POST["submitPerfil"]) && !empty($_POST["submitPerfil"])) {
$nombre=$_POST["nombreCompletoUsuario"];
$nick=$_POST["nickUsuario"];
$mail=$_POST["emailUsuario"];
$dni=$_POST["dni"];
$num=$_POST["numTelefonoUsuario"];
if($nombre==""){
echo "<br><br><br><br><font color='red'><strong>El nombre de usuario no puede estar vacío.</strong></font>";
}else if($nick==""){
echo "<br><br><br><br><font color='red'><strong>El nick del usuario no puede estar vacío.</strong></font>";
}else if($mail==""){
echo "<br><br><br><br><font color='red'><strong>El email del usuario no puede estar vacío.</strong></font>";
}else if(!filter_var($mail, FILTER_VALIDATE_EMAIL)){
echo "<br><br><br><br><font color='red'><strong>El email no posee el formato adecuado.</strong></font>";
}else if($num==""){
echo "<br><br><br><br><font color='red'><strong>El numero telefonico del usuario no puede estar vacío.</strong></font>";
}else if(!preg_match('/^[0-9]{9}+$/', $num)){
echo "<br><br><br><br><font color='red'><strong>El numero telefonico es incorrecto.</strong></font>";
}else{
changeProfile($conexion,$nombre,$nick,$mail,$num,$dni);
header("Location: login.php");
}
}
if(isset($_POST["submitPass"]) && isset($_POST["submitPass"])) {
$pass = $_POST["passUsuario"];
$Cpass = $_POST["confirmPassUsuario"];
if(!isset($pass) || strlen($pass) < 8){
echo "<br><br><br><br><font color='red'><strong>Contraseña no válida: debe tener al menos 8 caracteres.</strong></font>";
}else if(!preg_match("/[a-z]+/", $pass) || !preg_match("/[A-Z]+/", $pass) || !preg_match("/[0-9]+/", $pass)){
echo "<br><br><br><br><font color='red'><strong>Contraseña no válida: debe contener letras mayúsculas y minúsculas y dígitos.</strong></font>";
}else if($pass != $Cpass){
echo "<br><br><br><br><font color='red'><strong>La confirmación de contraseña no coincide con la contraseña.</strong></font>";
}else{
changeCPass($conexion, $dniUser,$pass);
changePass($conexion,$dniUser,$pass);
header("Location: login.php");
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<title>Perfil</title>
<?php include_once("headComun.php"); ?>
<link rel="stylesheet" type="text/css" href="css/error_form.css">
<link rel="stylesheet" type="text/css" href="css/perfil.css">
<script src="https://code.jquery.com/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="js/alta_usuario.js" type="text/javascript"></script>
</head>
<body>
<?php
if(isset($_SESSION['ADMIN'])){
include_once("navegacion_ADMIN.php");
}else{
include_once("navegacion.php");
}
?>
<div id="div_errores" class="error"></div>
<center>
<div class="col-5 col-tab-5 myTable">
<div>
<form action="perfil.php" id="formularioPerfil" method="POST" >
<div>
<label>Nombre Completo:</label>
<input oninput="nameValidation()" type="text" id="nombreCompletoUsuario" name="nombreCompletoUsuario" value="<?php echo $nameUser?>" ><br>
</div>
<div><label>Usuario:</label>
<input oninput="nickValidation()" type="text" id="nickUsuario" name="nickUsuario" value="<?php echo $nickUsuario?>" ><br>
</div>
<div><label>Email:</label>
<input oninput="emailValidation()" type="text" id="emailUsuario" name="emailUsuario" value="<?php echo $mailUser?>" ><br>
</div>
<div><label>DNI/NIF:</label>
<input readonly="" type="text" id="dni" name="dni" value="<?php echo $dniUser?>" ><br>
</div>
<div><label>Numero Teléfono:</label>
<input readonly="" oninput="phoneValidation()" type="text" id="numTelefonoUsuario" name="numTelefonoUsuario" value="<?php echo $numUser?>" ><br>
</div>
<div><label>Contraseña Actual:</label>
<input type="text" id="pass" name="pass" value="<?php echo $passUser?>" ><br>
</div>
<input class="changeProfile" type="submit" name="submitPerfil" value="Modificar Perfil">
</form>
</div>
 
 
 
 
 
 
<form action="perfil.php" id="cambiarPassPerfil" method="POST">
<label>Nueva Contraseña:</label><input oninput="passwordValidation()" onkeyup="passwordColor()" class="passUsuario" type="password" id="passUsuario" name="passUsuario" value=""><br>
<label>Confirmar Contraseña:</label><input oninput="retypeValidation()" class="confirmPassUsuario" type="password" id="confirmPassUsuario" name="confirmPassUsuario" value=""><br>
<input class="changePass" type="submit" name="submitPass" value="Cambiar Contraseña">
</form>
</div>
</center>
</body>
</html>