-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIngreso.php
120 lines (96 loc) · 3.78 KB
/
Ingreso.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
<?php
session_start();
$servername="localhost";
$username="root";
$password="Inicio94=";
$dbname="loginphp1";
// Funcion de Login
if (!empty($_POST['submit1'])){
$LUser = $_POST['UsuarioLog'];
$LClave = $_POST['ClaveLog'];
// Creamos la conexion
$conn = new mysqli($servername,$username,$password,$dbname);
if ($conn->connect_error){
die("Error en la conexion: ".$conn->connect_error);
}
$LClave=md5($LClave);
$sql ="SELECT Usuario,Clave FROM loginphp1.usuarios WHERE Usuario = '$LUser' AND Clave = '$LClave' ;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
//Salida de datos del query
while($row = $result->fetch_assoc()){
$_SESSION['user'] = $row["Usuario"];
//echo "Usuario: ".$row["Usuario"]."-Clave: ".$row["Clave"];
header("Location: perfil.php");
}
}
else{
echo "<script>alert('Sus Datos estan Incorrectos');</script>";
}
}
// Termina Funcion de Login
// Funcion de Registro
if (!empty($_POST['submit'])) {
$FNameF = $_POST['NameF'];
$FNameL = $_POST['NameL'];
$FUserName = $_POST['UserName'];
$FEmail = $_POST['Email'];
$FEmailR = $_POST['EmailR'];
$FPassword = $_POST['Password'];
$FPasswordR = $_POST['PasswordR'];
//echo $FNameF."<br>".$FNameL."<br>".$FUserName."<br>".$FEmail."<br>".$FEmailR."<br>".$FPassword."<br>".$FPasswordR ;
if ($FEmail==$FEmailR) {
if ($FPassword==$FPasswordR) {
$conn = new mysqli($servername,$username,$password,$dbname);
if ($conn->connect_error){
die("Error en la conexion: ".$conn->connect_error);
}
$FPasswordR =md5($FPasswordR);
$sql ="INSERT INTO usuarios (Nombre, Apellido, Email, Usuario, Clave) VALUES ('".$FNameF."','".$FNameL."','".$FEmailR."','".$FUserName."','".$FPasswordR."')";
if ($conn->query($sql) === TRUE) {
echo "<script>alert('El Registro Fue Agregado correctamente');</script>";
}
else{
echo "Error: " .$sql."<br>".$conn->error;
}
}
else{
echo "<script>alert('Las Contraseñas no son iguales');</script>";
}
}
else {
echo "<script>alert('Los campos de Correo electronico No Son Iguales');</script>";
}
}
// Termina Funcion de Registro
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="login">
<form action="index.php" method="POST">
Usuario: <input type="text" name="UsuarioLog"><br>
Clave: <input type="text" name="ClaveLog"><br>
<input type="submit" name="submit1" value="Entrar">
</form>
</div>
<div id= "Register">
<form action="index.php" method="POST">
Nombre: <input type="text" name="NameF"><br>
Apellido: <input type="text" name="NameL"><br>
Nombre de Usuario: <input type="text" name="UserName"><br>
Correo Electronico: <input type="text" name="Email"><br>
Repetir Correo Electronico: <input type="text" name="EmailR"><br>
Contraseña: <input type="password" name="Password"><br>
Repetir Contraseña;<input type="password" name="PasswordR"><br>
<input type="submit" name="submit" value="Registrar">
</form>
</div>
</body>
</html>