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

como chamar dados quando esta logado


tiago31

Pergunta

7 respostass a esta questão

Posts Recomendados

  • 0

Qual seu nivel de conhecimento em php?

Tem o script de login? Quando faz o login, provavelmente está salvando algumas informações em sessões, só precisa incrementar, salvando outras sessões com informações importantes que precisa, ou apenas salvando o ID do usuario.

Dai pra frente é só select na base de dados, filtrando resultados através desse ID.

Link para o comentário
Compartilhar em outros sites

  • 0

olha tenho conhecimento basico

mais a pagina de acesso restrito esta pronta e de login também e conecção

olhe

conect mysql

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_loguin = "localhost";
$database_loguin = "login1";
$username_loguin = "root";
$password_loguin = "vertrigo";
$loguin = mysql_pconnect($hostname_loguin, $username_loguin, $password_loguin) or trigger_error(mysql_error(),E_USER_ERROR); 
?>
logar.php
<?php require_once('Connections/loguin.php'); ?><?php
// *** Validate request to login to this site.
session_start();
$user = $_POST[user2];
$senha = $_POST[senha2];
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}


if (isset($user)) {
  $loginUsername = $user;
  $password      = $senha;
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "ola.php";
  $MM_redirectLoginFailed = "erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_loguin, $loguin);
  
  $LoginRS__query=sprintf("SELECT USER, SENHA FROM usuarios WHERE USER='%s' AND SENHA='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $loguin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;          

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}


if (isset($_POST['USER'])) {
  $loginUsername=$_POST['USER'];
  $password=$_POST['SENHA'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "ola.php";
  $MM_redirectLoginFailed = "erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_loguin, $loguin);
  
  $LoginRS__query=sprintf("SELECT USER, SENHA FROM usuarios WHERE USER='%s' AND SENHA='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $loguin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;          

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}

if (isset($_POST['USER2'])) {
  $loginUsername=$_POST['USER2'];
  $password=$_POST['SENHA2'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "ola.php";
  $MM_redirectLoginFailed = "erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_loguin, $loguin);
  
  $LoginRS__query=sprintf("SELECT USER, SENHA FROM usuarios WHERE USER='%s' AND SENHA='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $loguin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;          

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>


<?
include"link.php";
?>
<!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><?=$title?></title>
<style type="text/css">
<!--
body {
    background-color: #3285B6;
}
-->
</style>
<style type="text/css">
    @import url(menu_style.css); 
    @import url(menu_style1.css); 
</style>

</head>

<body>
<center>
<table width="20" border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" >
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="200" border="0" align="left">
          <tr>
            <td><img src="img/index.jpg" alt="" width="246" height="77" /></td>
          </tr>
        </table></td>
        <td><form action="<?php echo $loginFormAction; ?>" method="POST" name="logar" id="logar">
          <table width="200" border="0" align="right">
            <tr>
              <td><font size="2" face="Georgia, Times New Roman, Times, serif">Login:</font></td>
              <td><label>
                <input type="text" name="USER" id="USER" />
              </label></td>
              <td rowspan="2"><label>
                <input type="submit" name="entrar" id="entrar" value="Entrar" />
              </label></td>
            </tr>
            <tr>
              <td><font size="2" face="Georgia, Times New Roman, Times, serif">Senha:</font></td>
              <td><label>
                <input type="password" name="SENHA" id="SENHA" />
              </label></td>
            </tr>
            <tr>
              <td colspan="3"><table width="100%" border="0">
                <tr>
                  <td><font size="2" face="Arial, Helvetica, sans-serif" color="#61CC13">Esqueçeu a senha?</font></td>
                  <td><font size="2" face="Arial, Helvetica, sans-serif" color="#FF0000">Cadastre-se</font></td>
                </tr>
              </table></td>
            </tr>
          </table>
        </form></td>
      </tr>
      <tr>
        <td colspan="2">
        
<ul id="menu">
    <li><a href="<?=$pg?>" >Pagina Inicial</a></li>
    <li><a href="<?=$sp?>" >Super Planos </a></li>
    <li><a href="<?=$spcp?>" >Soluções para clientes e parceiros</a></li>
    <li><a href="<?=$par?>" >Parceiros</a></li>
    <li><a href="<?=$sup?>" >Suporte</a></li>
    <li><a href="<?=$ss?>" >Sobre o Site</a></li>
    <li><a href="<?=$log?>" ><font color="#EEE366">Login</font></a></li>
    <li><a href="<?=$cad?>" ><font color="#FF0000">Cadastre-se</font></a></li>
</ul>



</td>
      </tr>
      <tr>
        <td colspan="2" ><center>
          <img src="img/pro.jpg" width="936" height="120" />
        </center></td>
        </tr>
      <tr>
        <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" >
          <tr>
            <td width="20%" valign="top">
            <ul id="menu1">
    <li><a href="<?=$pg?>" >Pagina Inicial</a></li>
    <li><a href="<?=$log?>" ><font color="#EEE366">Login</font></a></li>
    <li><a href="<?=$cad?>" ><font color="#FF0000">Cadastre-se</font></a></li>
    <li><a href="<?=$spa?>" >Seja Parceiro</a></li>
    <li><a href="<?=$par?>" >Parceiros</a></li>
    <li><a href="<?=$ss?>" >Sobre o Site</a></li>
    <li><a href="<?=$cb?>" >Como Baixar</a></li>
    <li><a href="<?=$fp?>" >Formas de pagamento</a></li>
    <li><a href="<?=$tr?>" >Termos e Regras</a></li>
    <li><a href="<?=$blo?>" >Blog</a></li>
    <li><a href="<?=$sup?>" >contato</a></li>
</ul>
            
            </td>
            <td width="75%">
            
            <center><table width="100%" height="231" border="0">
              <tr>
                <td><center>
                  <form action="<?php echo $loginFormAction; ?>" method="POST" name="logar" id="logar">
                    <table width="200" border="0" >
                      <tr>
                        <td><font size="2" face="Georgia, Times New Roman, Times, serif">Login:</font></td>
                        <td><label>
                          <input type="text" name="USER2" id="USER2" />
                        </label></td>
                        <td rowspan="2"><label>
                          <input type="submit" name="entrar2" id="entrar2" value="Entrar" />
                        </label></td>
                      </tr>
                      <tr>
                        <td><font size="2" face="Georgia, Times New Roman, Times, serif">Senha:</font></td>
                        <td><label>
                          <input type="password" name="SENHA2" id="SENHA2" />
                        </label></td>
                      </tr>
                      <tr>
                        <td colspan="3"><table width="100%" border="0">
                          <tr>
                            <td><font size="2" face="Arial, Helvetica, sans-serif" color="#61CC13">Esqueçeu a senha?</font></td>
                            <td><font size="2" face="Arial, Helvetica, sans-serif" color="#FF0000">Cadastre-se</font></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table>
                  </form>
                </center></td>
              </tr>
              </table>  
              </center>
                  <p>&nbsp;</p></td>
            <td width="5%">&nbsp;</td>
          </tr>
        </table></td>
        </tr>
      <tr>
        <td colspan="2" align="center"><p><strong>Liberação em 24 horas ou seu dinheiro de volta</strong>.<br />
          *Obs.   Consulte os dados do servidor desejado</p></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><img src="img/segura.jpg" width="510" height="143" /></td>
      </tr>
      <tr>
        <td colspan="2"><center>Todos os Direitso Reservados Conta BR</center></td>
        </tr>
    </table></td>
  </tr>
</table>
</center>
</body>
</html>
acesso restrito
<?php
//initialize the 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_unregister('MM_Username');
  session_unregister('MM_UserGroup');
    
  $logoutGoTo = "logar.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "logar.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?
include"link.php";
?>
<!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><?=$title?></title>
<style type="text/css">
<!--
body {
    background-color: #3285B6;
}
-->
</style>
<style type="text/css">
    @import url(menu_style.css); 
    @import url(menu_style1.css); 
</style>

</head>

<body>
<center>
<table width="20" border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" >
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="72%"><table width="200" border="0" align="left">
          <tr>
            <td><img src="img/index.jpg" alt="" width="246" height="77" /></td>
          </tr>
        </table></td>
        <td width="28%">Seja bem vindo <?=$strUsers?></td>
      </tr>
      <tr>
        <td colspan="2"><ul id="menu">
          <li><a href="<?=$pg?>" >Pagina Inicial</a></li>
          <li><a href="<?=$sp?>" >Super Planos </a></li>
          <li><a href="<?=$spcp?>" >Soluções para clientes e parceiros</a></li>
          <li><a href="<?=$par?>" >Parceiros</a></li>
          <li><a href="<?=$sup?>" >Suporte</a></li>
          <li><a href="<?=$ss?>" >Sobre o Site</a></li>
          <li><a href="#" ><font color="#EEE366">Login</font></a></li>
          <li><a href="#" ><font color="#FF0000">Cadastre-se</font></a></li>
        </ul></td>
      </tr>
      <tr>
        <td colspan="2" ><center>
          <img src="img/pro.jpg" width="936" height="120" />
        </center></td>
      </tr>
      <tr>
        <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" >
          <tr>
            <td width="20%" valign="top"><ul id="menu1">
              <li><a href="ola.php" >Pagina Inicial</a></li>
              <li><a href="senha.php" ><font color="#FF6600">Senha</font></a></li>
              <li><a href="renovar.php" >Renovar</a></li>
              <li><a href="termos_uso.php" >Termos e Regras</a></li>
              <li><a href="<?=$cb?>" >Como Baixar</a></li>
              <li><a href="<?=$fp?>" >Formas de pagamento</a></li>
              <li><a href="<?=$sup?>" >contato</a></li>
              <li><a href="<?php echo $logoutAction ?>" ><font color="#EEE366">Sair</font></a></li>
            </ul></td>
            <td width="75%" valign="top"><center>
              <table width="375" border="0">
                <tr>
                  <td colspan="2"><center>
                    <font face="Verdana, Geneva, sans-serif" size="3">Meus Dados</font>
                  </center></td>
                </tr>
                <tr>
                  <td width="111">Nome:</td>
                  <td width="254">&nbsp;</td>
                </tr>
                <tr>
                  <td>Email:</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>Data de cadastro:</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </center>
              <table width="200" height="128" border="0">
                <tr>
                  <td><img src="img/logo.gif" width="338" height="38" /></td>
                  <td><img src="img/meg30.jpg" width="154" height="76" /></td>
                  <td><img src="img/meg30_pre.jpg" width="165" height="122" /></td>
                </tr>
                </table>
              <p>&nbsp;</p></td>
            <td width="5%">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><p><strong>Liberação em 24 horas ou seu dinheiro de volta</strong>.<br />
          *Obs.   Consulte os dados do servidor desejado</p></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><img src="img/segura.jpg" width="510" height="143" /></td>
      </tr>
      <tr>
        <td colspan="2"><center>
          Todos os Direitso Reservados Conta BR
        </center></td>
      </tr>
    </table></td>
  </tr>
</table>
</center>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

  • 0

Não sei como você está fazendo para logar, mas fiz um exemplo usando cookie.

<?php

if(isset($_COOKIE[login])){//verifica se está logado
$login = $_COOKIE['login'];

$select = mysql_query("SELECT * FROM sua_tabela WHERE login = '$login'");//procura algum login que seja igual a login

if(mysql_num_rows($select) >= 1){//se existir resultados
while($dados = mysql_fetch_assoc($select)){//cria um array
$nome = $dados['nome'];//pega os dados($dados variavel criada no while--['nome']=campo no sql)
}
}
}
?>

EDIT:

Desculpem, mas eu demorei demais para escrever e nesse tempo foram adicionadas 2 respostas xD mas faz parte.

Eu vou ver seu código...

Editado por vini_loock
Link para o comentário
Compartilhar em outros sites

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,3k
    • Posts
      652,3k
×
×
  • Criar Novo...