PHP - Necesito ayuda con este codigo que no hace nada

 
Vista:
sin imagen de perfil

Necesito ayuda con este codigo que no hace nada

Publicado por carmen (26 intervenciones) el 21/02/2014 21:03:21
Esto si funciona :

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
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Necesito ayuda con este codigo que no hace nada

Publicado por bathorz (33 intervenciones) el 22/02/2014 18:27:08
Cuando dices que no hace ni muestra nada, ¿te refieres a que la página está en blanco?.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Necesito ayuda con este codigo que no hace nada

Publicado por carmen (26 intervenciones) el 22/02/2014 19:37:23
Si en blanco. si errores nada.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Necesito ayuda con este codigo que no hace nada

Publicado por bathorz (33 intervenciones) el 22/02/2014 20:03:44
1
2
3
4
5
6
7
8
9
10
11
/**
 * borra todo y deja la consulta con un echo.
 */
echo $consulta = "SELECT * FROM `registro` "
   . "WHERE `usuario`='" . htmlentities($_POST['usuario']) . "' "
   . "AND `passuno`='" . htmlentities($_POST['passuno']) . "' "
   . "AND `licencia`='$oposicion'";
 
// Si puedes ver la consulta y los campos tienen valor agrega:
$sentencia = mysqli_prepare($con, $consulta);
var_dump($sentencia); // Si OK: bool(true)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar