Problema de autentificación!
Bueno mi problema es el siguiente... Recojo datos de usuario y contraseña, en el index.php
estos datos los mando a otra página "valida.php" pero el detalle es
k me dice k el usuario y contraseña no son correctos... Obviamente si
están los datos correspondientes en la BD de MySql
aquí dejo parte del código index.php
///////////////////////////
<form action="valida.php" method="post" name="formulario" id="formulario">
<p> </p>
<table width="200" border="1" align="center">
<tr>
<th scope="row"><span class="Estilo2 Estilo20">Usuario:</span></th>
<td><label>
<input type="text" name="tusuario" id="tusuario" />
</label></td>
</tr>
<tr>
<th scope="row"><span class="Estilo2 Estilo20">Contraseña:</span></th>
<td><input type="password" name="tpassword" id="tpassword" /></td>
</tr>
<tr>
<th scope="row"><label>
<input type="submit" name="button" id="button" value="Iniciar Session" />
</label></th>
<td><input type="reset" name="button" id="button" value="Cancelar" /></td>
</tr>
</table>
</form>
/////////////////////////////////////////////////
y aki el codigo de valida.php
session_start();
$bandera=0;
echo bandera;
echo "Nombre: ". $_POST["tusuario"];
$usuario = $_POST["tusuario"];
$password = $_POST["tpassword"];
$conectar = mysql_connect("localhost", "root", "");
$bd = mysql_select_db("cafe", $conectar);
echo "se ah conectado";
$consulta = mysql_query("select * from usuarios where usuario = '$usuario' and contrasena = '$password'", $conectar)or die ( mysql_error() );
while ($fila = mysql_fetch_row($consulta)
{
$tipo=$fila[3];
$bandera=1;
}
//echo "
";
if($bandera==0){?>
<script type="text/javascript"><!--
alert("Contraseña o Password incorrecto"); /*parent.location.href='index.php';*/
// --></script>
}
else
{
?>
$_SESSION["nombre"]=$usuario;$_SESSION["tipo"]=$tipo;
if($tipo=="U"){?>
<script type="text/javascript"><!--
parent.location.href="menu.php";
// --></script>
if($tipo=="A"){?>
<script type="text/javascript"><!--
parent.location.href="admin.php";
// --></script>
// Finalmente cerramos la conexión
mysql_close($conectar);
}
?>
estos datos los mando a otra página "valida.php" pero el detalle es
k me dice k el usuario y contraseña no son correctos... Obviamente si
están los datos correspondientes en la BD de MySql
aquí dejo parte del código index.php
///////////////////////////
<form action="valida.php" method="post" name="formulario" id="formulario">
<p> </p>
<table width="200" border="1" align="center">
<tr>
<th scope="row"><span class="Estilo2 Estilo20">Usuario:</span></th>
<td><label>
<input type="text" name="tusuario" id="tusuario" />
</label></td>
</tr>
<tr>
<th scope="row"><span class="Estilo2 Estilo20">Contraseña:</span></th>
<td><input type="password" name="tpassword" id="tpassword" /></td>
</tr>
<tr>
<th scope="row"><label>
<input type="submit" name="button" id="button" value="Iniciar Session" />
</label></th>
<td><input type="reset" name="button" id="button" value="Cancelar" /></td>
</tr>
</table>
</form>
/////////////////////////////////////////////////
y aki el codigo de valida.php
session_start();
$bandera=0;
echo bandera;
echo "Nombre: ". $_POST["tusuario"];
$usuario = $_POST["tusuario"];
$password = $_POST["tpassword"];
$conectar = mysql_connect("localhost", "root", "");
$bd = mysql_select_db("cafe", $conectar);
echo "se ah conectado";
$consulta = mysql_query("select * from usuarios where usuario = '$usuario' and contrasena = '$password'", $conectar)or die ( mysql_error() );
while ($fila = mysql_fetch_row($consulta)
{
$tipo=$fila[3];
$bandera=1;
}
//echo "
";
if($bandera==0){?>
<script type="text/javascript"><!--
alert("Contraseña o Password incorrecto"); /*parent.location.href='index.php';*/
// --></script>
}
else
{
?>
$_SESSION["nombre"]=$usuario;$_SESSION["tipo"]=$tipo;
if($tipo=="U"){?>
<script type="text/javascript"><!--
parent.location.href="menu.php";
// --></script>
if($tipo=="A"){?>
<script type="text/javascript"><!--
parent.location.href="admin.php";
// --></script>
// Finalmente cerramos la conexión
mysql_close($conectar);
}
?>
1 Respuesta
Respuesta de davidcortesb
1