Ver Mensaje Individual
  #11 (permalink)  
Antiguo 02/08/2013, 15:11
emilio_alac05
 
Fecha de Ingreso: septiembre-2012
Mensajes: 75
Antigüedad: 11 años, 7 meses
Puntos: 2
Respuesta: php manejo de session

este es el formulario para login
Código:
Código:
<form  action="validar.php" method="POST">
		 <table width="309" height="168" border="1" align="center">
      <tr>
        <td height="45" colspan="2" align="center"><strong>LOGIN USERS..</strong> </td>
      </tr>
      <tr>
        <td width="101" height="10" align="center"><strong>User</strong></td>
        <td width="192"><input name="nombre" type="text" size="30" style="height:28px"/></td>
      </tr>
      <tr>
        <td height="10" align="center"><strong>Password</strong></td>
        <td><input name="password" type="password" size="30" style="height:25px"/></td>
      </tr>
      <tr>
        <td height="34" colspan="2" align="center">
          <input type="submit" name="Submit" value="Accept"/>
		  <input type="reset" name="Submit" value="Clear"/>
        </td>
      </tr>
    </table>
	</form>
este es validar.php

Código PHP:
<?php 
    
include("conexion.php"); 
     
    if (!
$conexion) { 
        Echo 
"Error al conectar".mysqli_error();  
    } 
    if(!
$conect){ 
        echo 
"Error al seleccionar bd"mysqli_error(); 
    }                    
                      
    if(!isset(
$_SESSION)){ 
    
session_start(); 
    } 
      
       
$usuario=mysqli_real_escape_string($_POST['nombre']); 
       
$clave=mysqli_real_escape_string(md5($_POST['password'])); 
          
       
$consulta="Select * from usuarios where nom='$usuario' and pwd='$clave'"
       
$consultar=mysqli_query($consulta) or die(mysqli_error()); 
       
$re=mysqli_fetch_array($consultar); 

   if(!
$re[0]){ 
    echo 
"<script language= javascript> 
        alert('unauthenticated user') 
        location.href = 'login.php' 
        </script>"

    }else{ 
    
$_SESSION['Nombre']=$re['Nombre']; 
    
header("Location: index.php"); 
    } 

?>