Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/06/2020, 08:44
jolpuz
 
Fecha de Ingreso: junio-2005
Ubicación: Soy Latinoamericano pero
Mensajes: 95
Antigüedad: 18 años, 10 meses
Puntos: 0
Respuesta: incluir nombre de usuario en una pagina de bienvenida

Hola petit ! , gracias por tu respuesta y por la ayuda. siguiendo tus indicaciones llame a la variable a cual tengo en el php que inicia el login y de acuerdo a eso puse la variable que es la que reconoce el proceso en el login y resulto pero solo con el email del usuario...te explico :

Código PHP:
Ver original
  1. // este es el codigo php del login
  2.  
  3. <?php
  4.  
  5.     //INICIALIZAR LA SESION
  6.     session_start();
  7.    
  8.     if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
  9.         header("location: Welcome.php");
  10.         exit;
  11.     }
  12.  
  13. require_once "conexion.php";
  14.  
  15. $email = $password ="";
  16. $email_err = $password_err = "";
  17.  
  18. if($_SERVER["REQUEST_METHOD"] === "POST"){
  19.    
  20.     if(empty(trim($_POST["email"]))){
  21.         $email_err = "Please enter your email";
  22.     }else{
  23.         $email = trim($_POST["email"]);
  24.     }
  25.    
  26.     if(empty(trim($_POST["password"]))){
  27.         $password_err = "Please enter your password";
  28.     }else{
  29.         $password = trim($_POST["password"]);
  30.     }
  31.  
  32.    
  33.    
  34.    
  35.     //VALIDAR CREDENCIALES
  36.     if(empty($emai_err) && empty($password_err)){
  37.        
  38.         $sql = "SELECT id, usuario, email, pass FROM usuarios WHERE email = ?";
  39.        
  40.         if($stmt = mysqli_prepare($link, $sql)) {
  41.              
  42.             mysqli_stmt_bind_param($stmt, "s", $param_email);
  43.            
  44.             $param_email = $email;
  45.            
  46.             if(mysqli_stmt_execute($stmt)){
  47.                 mysqli_stmt_store_result($stmt);
  48.          }
  49.          
  50.             if(mysqli_stmt_num_rows($stmt) == 1){
  51.                 mysqli_stmt_bind_result($stmt, $id, $usuario, $email, $hashed_password);
  52.                 if(mysqli_stmt_fetch($stmt)){
  53.                     if(password_verify($password, $hashed_password)){
  54.                         session_start();
  55.                        
  56.                         //ALMACENAR DATOS EN VARIABLES DE SESION
  57.                         $_SESSION["loggedin"] = true;
  58.                         $_SESSION["id"] = $id;
  59.                         $_SESSION["email"] = $email;
  60.                        
  61.                         header("location: Welcome.php");
  62.                     }else{
  63.                         $password_err = " The password is incorrect";
  64.                     }
  65.                
  66.                 }
  67.             }else{
  68.                     $email_err = "The emal is non registered";
  69.                 }
  70.        
  71.         }else{
  72.                     echo "Somethong was wrong, try later";         
  73.         }
  74.     }
  75.  
  76.      mysqli_close($link);
  77. }
  78.  
  79.  
  80.  
  81. ?>



y este es el Login.php de la pagina

Código HTML:
// pagina de login


<?

include "code_login.php";

?>


<!doctype html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
	
<!-- Login  -->	
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, 
maximum-scale=1, minimun-scale=1">
<title>Login</title>
<link href="css/login.css" rel="stylesheet" type="text/css">
<link href="css/style-new.css" rel="stylesheet" type="text/css">
</head>

<body>
	
	<div class="container-all">
		<header >
			<a href="index.xhtml">Teach in line - Home</a>
		</header>
	<div class="ctn-form">
	<img src="images/logo-Lt-2.png" alt="" class="logo">
		<h1 class="title">Log in</h1>
		<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
		<label for="">Email</label>
		<input type="text" name="email">
		<span class="msg-error"><?php echo $email_err; ?></span>
		<label for="">Password</label>
		<input type="password" name="password">
		<span class="msg-error"><?php echo $password_err; ?></span>
		<input type="submit" value="Login Account">
		
		</form>
		
		<span class="text-footer">Are you New?
		<a href="Register.php">Register</a>
		</span>
		
		</div>	
	</div>
</body>
</html> 

Y esta es la pagina de bienvenida la cual incluiria el nombre de usuario, ahpra incluye el email del usuario ( gracias a ti y siguiendo tus indicaciones) pero me gustaria saber si puedo llamar al nombre del usuario.

Código HTML:
<?

   session_start();

if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
	header("location: Login.php");
	exit;
}

?>


<!doctype html>
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
	
<!-- Bienvenido -->	
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, 
maximum-scale=1, minimun-scale=1">
<title>Welcome</title>
<link href="css/login.css" rel="stylesheet" type="text/css">
</head>

<body>
	
	<div class="ctn-welcome">
	
	<img src="images/logo-Lt-2.png" alt="" class="logo-welcome">
	<h1 class="title-welcome">Welcome! </h1><p>to your lesson</p>
		<b><strong><?php echo $_SESSION['email']; ?></strong></b>
	<a href="cerrar_sesion.php" class="close-sesion">Log On</a>
	
	</div>
</body>
</html> 

Última edición por Triby; 17/06/2020 a las 09:14