Ver Mensaje Individual
  #18 (permalink)  
Antiguo 09/03/2011, 16:28
bariedto
 
Fecha de Ingreso: diciembre-2010
Ubicación: Ica
Mensajes: 28
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Codigo php para iniciar Sesion

me quedaria asi,.........

<?php
session_start();
if($_POST)
{
include('cn_conexion.php');
$nombre=$_POST['txtNombre'];
$clave=$_POST['txtclave'];
mysql_select_db('control', $conexion);
$sql="select * from usuarios where nombre='".$nombre."' and clave='".$clave."'";
$consulta=mysql_query($sql,$conexion);
$filas=mysql_num_rows($consulta);
if($consulta > 0)
{
session_start();
$_SESSION['usuario']=$nombre;
header("Location:portal.php");
}
else
{
header("Location:error.php");
}
}
?>
<html>
<head>
<title>Acceso</title>
</head>
<body>
<h1>Acceso Restringido</h1><br>
<hr>
<i>Por favor, ingrese su nombre de usuario y su clave </i><br>
<form name='f1' method='POST' action='conexion_usuario.php'>
<table border='0'>
<tr>
<td align='right'>Nombre de usuario</td>
<td align='left'><input type='textfield' name='txtNombre'></td>
</tr>
<tr>
<td align='right'>Clave</td>
<td align='left'><input type='password' name='txtclave'></td>
</tr>
<tr>
<td colspan='2' align='center'><input type='submit' value='ingresar'></td>
</tr>
</table>
<hr>
</form>
</body>
</html>



pero si lo pongo asi.....me redirecciona de inmediato a la pagina PORTAL.php..sin antes pedrime el usuario y la clave....pork???? TESEO----GATORv