Ir para conteúdo
Fórum Script Brasil
  • 0

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


mmousinho

Pergunta

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'); ?>
<?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";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

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

if (isset($_POST['Login'])) {
  $loginUsername=$_POST['Login'];
  $password=$_POST['Senha:'];
  $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">
<head>
<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">

</style>
</head>

<body>

<center>

<div id='conteudologinsistema'>

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

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

    <tr>
   
      <td align="center" bgcolor="#FFFFFF"><form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
      
  <table width="351" border="0">
    <tr>
      <td align="center" style="font-size: 12px"> <span>Entre com usuário e senha</span><br><br></td>
    </tr>
    
      <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>
    </tr><br>
    <tr>
     
      <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>
      
    </tr>
    <br />
    <tr>
      <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">
    <ul>
    <li><a  href="index.php">Ir para o site</a></li>
    </ul>
    
</div>
      
    </tr>
  
</td>
   
    </tr>
  
</table>


    </div>
    </center>

</body>
</html>

 

 

 

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>
            </a>

 

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

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...