Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  

Como colocar o nome do usuário logado no sistema PHP


Bom dia pessoal, sou novo em PHP e gostaria de uma ajuda, estou adapitando um layout no meu painel php e agostaria de colocar o usuário logado nele de acordo com o login que foi utilizado para logar no sistema.


Segue abaixo os códigos de validação...


<?php error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);require_once('Connections/config.php'); ?>
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  return $theValue;
// *** Validate request to login to this site.
if (!isset($_SESSION)) {

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];

if (isset($_POST['Login'])) {
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "painel.php";
  $MM_redirectLoginFailed = "erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_config, $config);
  $LoginRS__query=sprintf("SELECT Login, Senha FROM `usuário` WHERE Login=%s AND Senha=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
  $LoginRS = mysql_query($LoginRS__query, $config) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    header("Location: " . $MM_redirectLoginSuccess );
  else {
    header("Location: ". $MM_redirectLoginFailed );
<!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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login de Sistema MM</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">




<div id='conteudologinsistema'>

<table align="center" width="167" height="200" border="0">
      <th width="161" height="190" scope="col">
    <h6 style="font-size: 55px">SisWebMM</h6>

  <table align="center" width="351" height="200" border="0">

      <td align="center" bgcolor="#FFFFFF"><form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <table width="351" border="0">
      <td align="center" style="font-size: 12px"> <span>Entre com usuário e senha</span><br><br></td>
      <td align="center" colspan="3"><label for="Login"></label>
      <input style="color:#000"; type="text"  name="Login" placeholder="Usuário" onfocus="if (this.value=='Usuário') this.value='';" onblur="if (this.value=='') this.value='Usuário'"id="Usuário:"   maxlength="20" size="25" class="figurasemail" /></td> 

      <td align="center" colspan="3"><label for="Senha:"></label>
      <input style="color:#000" type="password" name="Senha:" placeholder="Senha"  onfocus="if (this.value=='Senha') this.value='';" onblur="if (this.value=='') this.value='Senha'"id="Senha:"   maxlength="8" size="25" class="figurassenha"  /></form></td>
    <br />
      <td height="65" colspan="4" align="center" valign="bottom"><br />
      <input type = "submit" name = "nome" value = "Entrar" p style = "color: black; cursor: pointer; background-color: white; font-size: 20px; font-weight: bold; width: 200; height: 145; font-family: verdana; border: 1px dotted #000000;"/>
<div id="menu">
    <li><a  href="index.php">Ir para o site</a></li>






E em outra pagina já do painel eu tenho uma área que gostaria de colocar o usuário conforme código abaixo.


 <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                          <span class="hidden-xs">          <!--Aparecer o nome do usuário logado??? -->      </span>


Desde já agradeço a compreenção e ajuda de todos.

Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Cloud Computing

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...