Código PHP:
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['s_username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['s_username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Explosion Total ::: Musica, Chistes, Chat, Videos, y mucho mas!</title>
<link rel="stylesheet" href="images/style.css" type="text/css" media="screen" />
<style type="text/css">
<!--
.Estilo1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
</head>
<body>
<div id="wrapper">
<div id="header" title="Explosion Total">
<h1> </h1>
<center><h2> </h2>
</center>
</div>
<div id="menu">
<ul>
<li><a href="./">Inicio</a></li>
<li><a href="#">Musica</a></li>
<li><a href="chistes">Chistes</a></li>
<li><a href="videos">Videos</a></li>
<li><a href="comentario">Dejame Tu Comentario </a></li>
<?php
// Configura la información de tu cuenta
$dbhost='localhost';
$dbusername='root';
$dbuserpass='';
$dbname='usuarios';
// Conexión a la base de datos
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Disculpe Hay Problemas Con Nuestra Base De Datos');
if (isset($_SESSION['s_username'])) {
echo "<strong><li>Bienvenido, ".$_SESSION['s_username']."!</li></strong><li><a href='$logoutAction' title='Salir'>Salir</a></li>";
}else{
echo "<li><a href='user/reg1.php'>Registrate</a></li><li><a href='user/entra.php'>Ingresa</li></a>";
}
?>
</ul>
</div>
<div id="sidebar">
<div id="feed" title="Proximamente">
<a class="feed-button" href="#">*</a>
</div>
<ul>
<li><a href="#">Link One</a></li>
<li><a href="#">Link Two</a></li>
<li><a href="#">Link Three</a></li>
<li><a href="#">Link Four</a></li>
<li><a href="#">Link Five</a></li>
</ul>
<div id="sidebar-bottom">
</div>
</div>
<div id="content">
<div id="asd">
<?php
/*escogemos un numero aleatorio, 1 de 3 posibles resultados (0, 1 o 2) */
$numRandom = rand(0,2);
switch($numRandom) {
case 0:
$img = "barner.png";
$alt="Puedes Anunsiarte Aqui! Sin Costo alguno!";
break;
case 1:
$img = "barner1.png";
$alt="Vamos danos tu barner y Te anunsiamos";
break;
case 2:
$img = "barner2.png";
$alt="Por Que estamos creciendo te anunsiamos Gratis!";
break;
}
?>
<a href="contacto/contacto.php"><img src="<?php echo $img;?>" alt="s" border="2" title="<?php echo $alt?> "/></a></div>
<div class="entry">
<div class="entry-title">
<div align="center"><a href="#">Perfil De Usuario </a></div>
</div>
<div class="date">Posted on 30 November 2006</div>
<?php
$connect=mysql_connect("localhost","root","");
mysql_select_db("usuarios",$connect);
$nick=$_SESSION['s_username'];
$query=mysql_query("SELECT * FROM user WHERE username='$nick'",$connect);
// despues obtines todos los datos que quieras y los guardas en la sesion
?>
</div>
</div>
<div id="footer">
<div id="footer-valid">
<a href="http://validator.w3.org/check/referer">xhtml</a> / <a href="http://www.forosdelweb.com/">Foros Del Web!</a>
</div>
</div>
</div>
</body>
</html>