index.php
Código HTML:
<form action="validar.php" method="post" name="form"> <center> <table border="0"> <tr> <td> Usuario: </td> <td> <input name="login" type="text" id="login" /> </td> </tr> <tr> <td> Clave: </td> <td> <input name="password" type="password" id="password" /> </td> </tr> <tr> <td> <input type="submit" value="Enviar" /> </td> <td> <input type="reset" value="Borrar" /> </td> </tr> </table> </center> </form>
Código PHP:
<?php
if ($_REQUEST['login']!="" and $_REQUEST['password']!="")
{
// Abro base de datos
$tabla = "usuarios";
require('conectarse.php');
$link=conectarse();
$consulta = "select activo from $tabla where login='$_REQUEST[login]' and password='$_REQUEST[password]'";
$resultado=mysql_query($consulta,$link);
$numregistros=mysql_numrows($resultado);
if($numregistros!=0)
{
$_REQUEST['activo']=mysql_result($resultado,$i,'activo');
if ($_REQUEST['activo']=='1')
{
echo "Es un usuario Administrativo.";
?>
<A href='menuadmin.php'>Continuar</a>
<?php
}
else
{
echo "Usuario ingreso correctamente.";
?>
<A href='comentario.php'>Continuar</a>
<?php
}
}
else
{
echo "Login o password incorrectos.";
echo " <a href='index.php'>Intentar de Nuevo";
}
}
else
{
echo "Login o password incorrectos.";
echo " <a href='index.php'>Intentar de Nuevo";
}
?>
El problema que tengo es que cuando yo ingreso directamente a comentario.php sin iniciar sesion me carga el formulario y me deja enviar un mensaje,
Como hago para que cuando yo ingrese directamente a comentario.php me pida haber iniciado sesion?
Gracias!!