Note that there are some explanatory texts on larger screens.

plurals
  1. POWhats wrong with this php code that goes directly in without having log in first?
    primarykey
    data
    text
    <p>I have a form that only opens if you're logged in, or at least thats what I'm trying to do, but it opens without having to do it. When I go to the log in page it sends me to the other page like if I was logging in, but it doesn't even show me the login page, heres the code:</p> <p>this one is for the log in:</p> <pre><code>&lt;?php include ("conexion/conexion.php"); include("usuarios.class.php"); $usuario= $_POST['usuario']; $clave= $_POST['clave']; $objUsuario = new usuarios; $srt= $objUsuario-&gt;autenticar_usuario($usuario,$clave,1); $num =mysql_num_rows($srt); if($usuario=="" || $clave==""){ $mensaje="campos en blanco"; header("location:loginusuario.php?mensaje=$mensaje"); }else { $objUsuario = new usuarios; $srt= $objUsuario-&gt;autenticar_usuario($usuario,$clave,1); $num =mysql_num_rows($srt); } if($num &lt;= 0){ $mensaje="Usuario y/o clave Incorrectos"; header("location:loginusuario.php?mensaje=$mensaje"); }else{ $row=mysql_fetch_array($srt); session_start(); $_SESSION['log'] = 's'; $_SESSION['nombre'] = $row['nombre']; header("location:contrataciones.php"); } ?&gt; </code></pre> <p>this is for the security file:</p> <pre><code>&lt;?php session_start(); if($_SESSION['log']!= 's'){ $mensaje="Iniciar sesion"; header("location:loginusuario.php?mensaje=$mensaje"); } ?&gt; </code></pre> <p>and this is the class I'm using</p> <pre><code>&lt;?php class usuarios { function usuarios() { } function autenticar_usuario($usuario,$clave){ $sel="select usuario,clave from usuarios where usuario='".$usuario."' and clave='".$clave."' "; $srt=mysql_query($sel) or die($sel); return $srt; } ?&gt; </code></pre> <p>please tell me what am I doing wrong I'm a noob in this so I dont really get whats the problem</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload