ingreso usuario y contraseña y si la contraseña existe en la base de datos se loguea con cualquier nombre.
login.php
Código PHP:
   <?php
session_start();
if(isset($_SESSION['sesion_exito']))
    {
    if($_SESSION['sesion_exito']==2)
        {
            echo "Los campos SON OBLIGATORIOS";
        }
    if($_SESSION['sesion_exito']==3)
        {
            echo "DATOS INCORRECTOS";}
        }
else
{
    $_SESSION['sesion_exito']=0;
}
?>
<?php
if($_SESSION['sesion_exito']==4)
    {
        echo "GRACIAS POR USAR NUESTROS SERVICIOS";
    }
$_SESSION['sesion_exito']=0; 
?> 
<form action="index.php" method="post">
 
  <h1>Login de Usuario</h1>
 
  <fieldset>
    <legend>Complete los datos:</legend>
 
    <ul> 
      <li>
        <label for="usuario">Usuario:</label>
        <input type="text" name="user" placeholder="Usuario" required="required" maxlength="10" />
      </li>
         
      <li>
        <label for="contra">Password:</label>
        <input type="password" name="pass" placeholder="Contraseña" required="required" maxlength="10" />
      </li>
    </ul>
 
  </fieldset>
    <input id="login" type="submit" name="index" value="INICIAR SESIÓN" />
</form>   Código PHP:
   <?php
    session_start();
 
    if(isset($_POST['index']))
    {
      $_SESSION['sesion_exito']=0;
 
      $user = $_POST['user'];
      $pass = $_POST['pass'];
 
      if($user=="" || $pass=="")
      {
        $_SESSION['sesion_exito']=2;
      }
      else
      {
        include("conexion.php");  
        $_SESSION['sesion_exito']=3;
        $resultados = mysqli_query($conexion,"SELECT user,pass FROM $table_9 WHERE user='$user' AND pass='$pass'");
        while(mysqli_fetch_array($resultados))
            {
               $_SESSION['sesion_exito']=1;
            }
        include("cerrarconexion.php");
      }
    }
 
    if($_SESSION['sesion_exito']<>1)
    {
      header('Location:login.php');
    }
?>     
 



