creas la primera pagina para logearte.
index.php (por ejemplo)
Cita: <table width="78%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center" class="Estilo1">Ingrese la contraseña de acceso </div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><form action="logeo.php" method="post" enctype="multipart/form-data" name="frm" target="_self">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table onMouseMove="this.style.backgroundColor='#CCCCFF'" onMouseOut="this.style.backgroundColor=''" style="border-width:0px " width="63%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#990000">
<tr>
<td valign="top"><table width="92%" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td><table width="88%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>Usuario</td>
<td><input onKeyPress="alfanumerico(this)" name="usuario" type="text" id="usuario" style="border-style: ridge; height:20px " maxlength="20"></td>
</tr>
<tr>
<td width="36%">Contraseña</td>
<td width="64%"><input onKeyPress="alfanumerico(this)" name="clave" type="password" id="clave" style="border-style: ridge; height:20px " maxlength="20"></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">
<input name="enviar" onClick="javascript:validar();" type="button" class="" id="enviar" style="border-style:groove; background-color:#ECFFEC; color:#000000; " value="Entrar">
</div></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
luego creas el archivo
logout.php y principal.php (aqui ya se muestra todo en contenido para el usuario)
Código PHP:
<?php
require("conexion.php");
ob_start();
$usuario=$_POST['usuario'];
$clave=$_POST['clave'];
$clave=str_replace("'","x",$clave);
$usuario=str_replace("'","x",$usuario);
session_name();
session_start('usuario');
if (session_is_registered('usuario'))
{ $url="location: principal.php"; header($url); ob_end_flush(); exit;}
$sql="select * from usuarios where clave='$clave' and usuario='$usuario' ";
$r=mysql_query($sql) or die("No se puede consultar!");
if ($f=mysql_fetch_array($r))
{
session_name();
session_start();
session_register('usuario');
session_encode(); die("entra <a href='principal.php'>entrar</a>");
$url="location: principal.php"; header($url);
}
else
{ $url="location: index.php"; header($url); }
ob_end_flush();
?>
Todos tus demas pagianas que vera el usuario debe tener lo siguiente... al inicio.
[PHP
<?php
ob_start();
session_name();
session_start('usuario');
if (!session_is_registered('usuario'))
{
session_unset(); session_destroy(); $url="location: index.php"; header($url); exit;
}
else
{ $usuario=$_SESSION['usuario']; }
require("conexion.php");
?>
[/PHP]
y al final de todas la paginas que vera solo el usuario debe ir
Código PHP:
<? mysql_close(); ob_end_flush(); ?>
puedes hacer dos archivos como cebezera.php y pie.php
de modo que en cada web sea algo asi
Código PHP:
<? require("cebezera.php");?>
<html>
///Contenido HTMLLLLLLLLLL o PHP
</html>
<? require("pie.php");?>
eso es todo...
bye