
Necesito ayuda con este codigo que no hace nada
Publicado por carmen (26 intervenciones) el 21/02/2014 21:03:21
Esto si funciona :
Lo que no funciona...
Sencillamente no hace nada, no da errores pero tampoco devuelve nada.
lo que quiero cuando un usuario haga login la consulta mire si ese usuario y esa contraseña este registrada, si lo esta
y tiene una licencia $fgh = 'fgh'; $dfg = 'dfg'; $ttl = 'ttl'; dependiendo de caul se la variable que se la asigno abajo en la consulta me habra una pagina determinada.
espero vuestras sugerencias 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
if(isset($_POST['usuario'])&&!empty($_POST['usuario'])&&
isset($_POST['passuno'])&&!empty($_POST['passuno'])){
$consulta = "SELECT * FROM `registro` WHERE `usuario` = '".htmlentities($_POST['usuario'])."' AND `passuno` = '".htmlentities($_POST['passuno'])."'
AND `licencia` = '$oposicion'";
$sentencia = mysqli_prepare($con, $consulta);
mysqli_stmt_execute($sentencia);
/* almacenar el resultado */
mysqli_stmt_store_result($sentencia);
$resultado = mysqli_stmt_num_rows($sentencia);
if($resultado != 0) {
?>
<script language="javascript">
alert("Ha echo usted log in.");
window.location="inicioghj.html";
</script>
<?
}
?>
<script language="javascript">
alert("No esta usted registrado.");
window.location="registro.html";
</script>
<?
} /* aqui termina if(isset($_POST['usuario'])*/
else {
?>
<script language="javascript">
alert("Debe rellenar todos los campos.");
window.location="index.html";
</script>
<?
}
Lo que no funciona...
Sencillamente no hace nada, no da errores pero tampoco devuelve nada.
lo que quiero cuando un usuario haga login la consulta mire si ese usuario y esa contraseña este registrada, si lo esta
y tiene una licencia $fgh = 'fgh'; $dfg = 'dfg'; $ttl = 'ttl'; dependiendo de caul se la variable que se la asigno abajo en la consulta me habra una pagina determinada.
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
$usuario = $_POST['usuario'];
$passuno = $_POST['passuno'];
$fgh = 'fgh';
$dfg = 'dfg';
$ttl = 'ttl';
$oposicion = '';
switch($oposicion) {
case $fgh:
if(isset($_POST['usuario'])&&!empty($_POST['usuario'])&&
isset($_POST['passuno'])&&!empty($_POST['passuno'])){
$consulta = "SELECT * FROM `registro` WHERE `usuario` = '".htmlentities($_POST['usuario'])."' AND `passuno` = '".htmlentities($_POST['passuno'])."'
AND `licencia` = '$oposicion'";
$sentencia = mysqli_prepare($con, $consulta);
mysqli_stmt_execute($sentencia);
/* almacenar el resultado */
mysqli_stmt_store_result($sentencia);
$resultado = mysqli_stmt_num_rows($sentencia);
if($resultado != 0) {
?>
<script language="javascript">
alert("Ha echo usted log in.");
window.location="inicioghj.html";
</script>
<?
}
?>
<script language="javascript">
alert("No esta usted registrado.");
window.location="registro.html";
</script>
<?
} /* aqui termina if(isset($_POST['usuario'])*/
else {
?>
<script language="javascript">
alert("Debe rellenar todos los campos.");
window.location="index.html";
</script>
<?
}
break;
case $dfg:
if(isset($_POST['usuario'])&&!empty($_POST['usuario'])&&
isset($_POST['passuno'])&&!empty($_POST['passuno'])){
$consulta = "SELECT * FROM `registro` WHERE `usuario` = '".htmlentities($_POST['usuario'])."' AND `passuno` = '".htmlentities($_POST['passuno'])."'
AND `licencia` = '$oposicion'";
$sentencia = mysqli_prepare($con, $consulta);
mysqli_stmt_execute($sentencia);
/* almacenar el resultado */
mysqli_stmt_store_result($sentencia);
$resultado = mysqli_stmt_num_rows($sentencia);
if($resultado != 0) {
?>
<script language="javascript">
alert("Ha echo usted log in.");
window.location="inicioghj.html";
</script>
<?
}
?>
<script language="javascript">
alert("No esta usted registrado.");
window.location="registro.html";
</script>
<?
} /* aqui termina if(isset($_POST['usuario'])*/
else {
?>
<script language="javascript">
alert("Debe rellenar todos los campos.");
window.location="index.html";
</script>
<?
}
break;
case $ttl:
if(isset($_POST['usuario'])&&!empty($_POST['usuario'])&&
isset($_POST['passuno'])&&!empty($_POST['passuno'])){
$consulta = "SELECT * FROM `registro` WHERE `usuario` = '".htmlentities($_POST['usuario'])."' AND `passuno` = '".htmlentities($_POST['passuno'])."'
AND `licencia` = '$oposicion'";
$sentencia = mysqli_prepare($con, $consulta);
mysqli_stmt_execute($sentencia);
/* almacenar el resultado */
mysqli_stmt_store_result($sentencia);
$resultado = mysqli_stmt_num_rows($sentencia);
if($resultado != 0) {
?>
<script language="javascript">
alert("Ha echo usted log in.");
window.location="inicioghj.html";
</script>
<?
}
?>
<script language="javascript">
alert("No esta usted registrado.");
window.location="registro.html";
</script>
<?
} /* aqui termina if(isset($_POST['usuario'])*/
else {
?>
<script language="javascript">
alert("Debe rellenar todos los campos.");
window.location="index.html";
</script>
<?
}
break;
}
mysqli_close($con);
espero vuestras sugerencias gracias.
Valora esta pregunta


0