PHP - Login en php

 
Vista:
sin imagen de perfil

Login en php

Publicado por Pablo (10 intervenciones) el 26/09/2017 11:09:19
Buenas, tengo el siguiente código:
necesitaría saber como se pueden comparar el email y la contraseña para que pueda iniciar sesión, gracias

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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Login - Sistema Alternativo</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 
  <!-- PANEL BOTON DESPLEGABLE -->
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
 
</head>
<style>
/* BARRA SCROLL*/
 
body::-webkit-scrollbar-track {
	-webkit-box-shadow: inset 0 0 6px #666666;
	background-color: #F5F5F5;
	border-radius: 10px;
}
 
body::-webkit-scrollbar
{
	width: 10px;
	background-color: #F5F5F5;
}
 
body::-webkit-scrollbar-thumb
{
	border-radius: 10px;
	background-color: #333;
 
}
 
/* FIN BARRA SCROLL*/
 
 
/* Full-width input fields */
input[type=text], input[type=password] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 4px solid #ccc;
    box-sizing: border-box;
	font-size:18px;
}
 
/* Set a style for all buttons */
button {
    background-color: #4CAF50;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    cursor: pointer;
    width: 100%;
}
 
/* Extra styles for the cancel button */
.cancelbtn {
    padding: 14px 20px;
    background-color: #f44336;
}
 
/* Float cancel and signup buttons and add an equal width */
.cancelbtn,.signupbtn {
    float: left;
    width: 50%;
}
 
/* Add padding to container elements */
.container {
    padding: 16px;
}
 
/* Clear floats */
.clearfix::after {
    content: "";
    clear: both;
    display: table;
}
 
/* Change styles for cancel button and signup button on extra small screens */
@media screen and (max-width: 300px) {
    .cancelbtn, .signupbtn {
       width: 100%;
    }
}
 
.active {
	background-color: #42474a;
	text-align:center;
	color:rgb(255,255,255);
	font-size:18px;
	padding:9px;
	}
.glyphicon {
	font-size: 36px;
	color:#F60;
	padding:4px;
	}
 
.container {
	width:400px;
	height:auto;}
</style>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--NAV - MENU -->
<nav class="navbar navbar-inverse" style="-webkit-box-shadow: 0px 9px 5px 2px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 9px 5px 2px rgba(0,0,0,0.75);
box-shadow: 0px 9px 5px 2px rgba(0,0,0,0.75);">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#"></a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li><a href="index.html" data-toggle="tooltip" title="Volver a Casa"><span class="glyphicon glyphicon-home"></span></a></li>
        <li><a href="#" data-toggle="tooltip" title="¿Necesitas Ayuda?"><span class="glyphicon glyphicon-question-sign"></span></a></li>
       <!-- <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">AYUDA<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>-->
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="registrate.php" data-toggle="tooltip" title="¿Todavia no eres uno de nuestro usuario? REGISTRATE AHORA MISMO, ES GRATIS"><span class="glyphicon glyphicon-user"></span></a></li>
      </ul>
    </div>
  </div>
</nav>
<!--FIN NAV-->
 
<!--FORMULARIO DE LOGIN-->
<section class="active">
<figure><img src="images/logo-11.png" style=" width:30%; margin-top:0px;"></figure>
 
<h2>Area de Cliente</h2>
</section>
 
<section>
<form action="login/perfil-usuario.php" style="border:2px solid #ccc;">
<div class="help">
<!-- COMO PODEMOS AYUDARTE PENDIENTE PARA ANALIZAR 
<a href="#" data-toggle="tooltip" title="¿Cómo podemos ayudarte?"><span class="glyphicon glyphicon-question-sign"></span></a>
</div>
FIN -->
 
<div class="container">
    <label><b>Email:</b></label>
    <input type="text" placeholder="Ingresa tu Email" name="email" required>
 
    <label><b>Contraseña:</b></label>
    <input type="password" placeholder="************" name="contrasena" required>
 
    <input type="checkbox" checked="checked"> Recuérdame
    <p>Acepta Nuestros <a href="#">Términos y Privacidad</a>.</p>
    <button class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg" style="width:auto; background-color:rgb(51,51,51);">¿Olvidaste tu contraseña?</button>
 
    <div class="clearfix">
      <button type="button" class="cancelbtn">CANCELAR</button>
      <button type="submit" class="signupbtn">INICIAR</button>
    </div>
  </div>
 
 
<!-- Iniciar Sesion  -->
 
<?php
 
 
 if($_POST){
 
$conexion=mysqli_connect("localhost","root","","sisalt") or
    die("Problemas con la conexión");
 
$email=$_POST['email'];
$contrasena=$_POST['contrasena'];
 
 
$registros=mysqli_query($conexion,"select * from registro where contrasena='".$contrasena."'") or
  die("Problemas en el select:".mysqli_error($conexion));
 
 
if ($reg=mysqli_fetch_array($registros))
{
 echo "ok La contraseña <b>".$contrasena."</b> ya fue elegida por otro usuario.";
     exit();
 
}
 
 
mysqli_close($conexion);
 
 
}
 
 
?>
 
</form>
</section>
 
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <h2>Restabler contraseña</h2>
      <input type="text" name="forget" placeholder="Email asociado a tu cuenta" style="width:80%; border-radius:10px;"><a href="#"> Restablecer</a>
    </div>
  </div>
</div>
 
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder