Ver Mensaje Individual
  #6 (permalink)  
Antiguo 27/11/2013, 11:31
Cydrex
 
Fecha de Ingreso: febrero-2013
Mensajes: 20
Antigüedad: 11 años, 3 meses
Puntos: 0
Respuesta: Como puedo poner una consulta de un usuario concreto

Ya probe todo eso y nada, mejor os dejo todos los archivos para que veais como funciona..

Index.php:
Código:
<!doctype html>
<html lang="es">
	<head>
		<meta charset='utf-8'>
		<link rel="stylesheet" href="style.css">
		<link href='http://fonts.googleapis.com/css?family=Russo+One' rel='stylesheet'>
	</head>
	<body>
		<div id='contenido'>
			<header>
				<hgroup>
					<h1>Gamonic</h1>
				</hgroup>
			<nav>
				<ul>
					<li><a class="button azul" href='Index.html'>Inicio</a></li>
					<li><a class="button azul" href='Register.html'>Registro</a></li>
					<li><a class="button azul" href='Login.html'>Conecta</a></li>
				</ul>
			</nav>
		  </header>
		  <section>
		  	<div id='textoPr'>
		  		<article>
		  			<hgroup>
		  				<h1>Diviertete en el mayor mmo via web en español</h1><br>
		  			</hgroup>
		  			<center>
		  			<form action="login.php" method="post">
		  				<table width"200" border="0">
		  					<tr>
		  						<td>Usuario:</td>
		  						<td><input type="text" name="user"></td>
		  					</tr>
		  					<tr>
		  						<td>Contraseña:</td>
		  						<td><input type="password" name="pass"></td>
		  					</tr>
		  					<tr>
		  						<td><input type="submit" value="Entrar"</td>
		  					</tr>
		  				</table>
		  			</form>
		  			</center>
		  	</div>
		  </section>
		</div>
	</body>
</html>
Login.php:
Código:
<?php
session_start();
include("conexion.php");

if(isset($_POST['user']) && !empty($_POST['user']) &&
isset($_POST['pass']) && !empty($_POST['pass']))
{
	$con=mysql_connect($host,$user,$pass,$db)or die ("Problemas con servidor");
	mysql_select_db($db,$con)or die("Problemas con BD");

		$sel=mysql_query("SELECT Usuario,Contra FROM registro WHERE Usuario = '$_POST[user]'",$con);

$sesion=mysql_fetch_array($sel);


if($_POST['pass'] == $sesion['Contra']){
	$_SESSION['username'] = $_POST['user'];
	
	header("Location: PreMe.php");
}
else{
	echo "Combinacion mal";
}

}else{
	echo "Debes llenar todos los campos";
}

?>
PreMe.php:
Código:
<?php
session_start();

if(isset($_SESSION['username'])){
	include("Me.php");
}else{
	echo"No puedes ver esta pagina";
}
?>
Me.php:
Código:
<!doctype html>
<html lang="es">
	<head>
		<?php
		include("conexion.php");
		?>
		<meta charset='utf-8'>
		<link rel="stylesheet" href="style.css">
		<link href='http://fonts.googleapis.com/css?family=Russo+One' rel='stylesheet'>
	</head>
	<body>
		<div id='contenido'>
			<header>
				<hgroup>
					<h1>Gamonic</h1>
				</hgroup>
			<nav>
				<ul>
					<li><a class="button azul" href='Me.php'>Inicio</a></li>
					<li><a class="button azul" href='Tienda.php'>Tienda</a></li>
					<li><a class="button azul" href='Guia.php'>Guia</a></li>
					<li><a class="button azul" href='Salir.php'>Salir</a></li>
				</ul>
			</nav>
		  </header>
		  <section>
		  	<div id='textoPr'>
		  		<article>
		  			<hgroup>
		  				<h1>¡Bienvenido <?php

						$con = mysql_connect($host,$user,$pass,$db); 
						mysql_select_db("db", $con); 
						$result = mysql_query("SELECT Usuario FROM registro", $con); 
						if ($row = mysql_fetch_array($result)){ 
							echo $row['Usuario'];
						}

					?> a Gamonic!</h1><br>
		  			</hgroup>
		  			<center>
		  			
		  			
		  			</center>
		  	</div>
		  </section>
		</div>
		<a href='Destroy.php'>Cerrar Sesion</a>
	</body>
</html>
Lo puse en orden de donde inicia sesion hasta el Me.php