Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Bruno Moura

[Resolvido] Como declarar e utilizar variave de session

Recommended Posts

Boa tarde pessoal sou iniciante em php e estou desenvolvendo um pequena aplicação para o trabalho, ja fiz

o cadastro de curriculo, faleconosco,cadastro de usuarios e de departamentos.

Em uma area administrativa eu crirei um formulario de login, esta logando beleza

agora queria pegar o nome do usuario e o codigo do departamento para que quando

ele for listar o faleconosco venha so os registros do departamento do usuario.

e imprimir em uma regiao o nome do usuario que esta logado.

Ja pesquisei mas nao estou conseguinto colocar em pratica.

Alguem tem alguma dica ???

 

aqui esta meu arquivo sendlogin , apos ele que eu queria pegar o nome e o codigo do departamento para

colocar na pagina do menu adminstrativo.

<?php
//conecta com o db 


include ("conectar.php"); 
$login= $_POST['txtlogin']; 
$senha = $_POST['txtpasswd'];
 

$criplogin = base64_encode($login);
$cripsenha = base64_encode($senha);

//faz a confirmação de nome e senha no db 
$logar = mysql_query("SELECT * FROM usuario WHERE usu_login='$criplogin' AND usu_senha='$cripsenha'") or 
die("erro ao selecionar");



//session["usu_nome"]=$nome;
/*aqui depois de verificado redirecionamos a pagina secreta(caso nome e senha estarem 
corretos) ou senha 
e apelido não conferem caso tais estiverem errados. Repare que há uma rotina para o valor 
inserido em senha não seja nulo. 
 
obs: Aonde esta escrito paginasecreta.php é aonde você deve colocar a página para onde o script 
ira redirecionar*/ 

if (strlen($cripsenha )< 1) 
echo '<p align="center">Senha ou apelido nao conferem<BR><a 
href="java script:history.back(1);">tente denovo</a></p>'; 
elseif (mysql_num_rows($logar)>0 ){ 
header("location:frmmenuconsulta.php"); 
} else { 
echo '<p align="center">Senha ou apelido nao conferem<BR><a 
href="java script:history.back(1);">tente denovo</a></p>'; 
} 
?>

aqui esta meu arquivo do menu de consulta do sistema

<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->

<title>Cadastro de Curriculo - Cooperatica Agricola Mista Acegua Ltda.</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//---------------   END LOCALIZEABLE   ---------------
</script>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {font-weight: bold}
.style3 {font-weight: bold}
.style4 {font-weight: bold}
.style5 {font-weight: bold}
.style6 {font-weight: bold}
.style7 {font-weight: bold}
.style8 {font-weight: bold}
.style9 {font-weight: bold}
.style10 {font-weight: bold}
.style11 {font-weight: bold}
.style12 {font-weight: bold}
.style13 {font-weight: bold}
.style14 {font-weight: bold}
.style15 {font-weight: bold}
.style16 {font-weight: bold}
.style17 {font-weight: bold}
-->
</style>
</head>

<body bgcolor="#F4FFE4">
<table width="995" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#D5EDB3">
	<td colspan="3" rowspan="2"><img src="logo camal.JPG" alt="" width="228" height="102" /></td>
	<td height="50" id="logo" valign="bottom" align="center" nowrap="nowrap">Cooperativa Agricola Mista Aceguá Ltda.</td>
	<td width="12"> </td>
  </tr>

  <tr bgcolor="#D5EDB3">
	<td height="51" id="tagline" valign="top" align="center"><marquee>CAMAL</marquee></td>
	<td width="12"> </td>
  </tr>

  <tr>
	<td colspan="5" bgcolor="#5C743D"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

  <tr>
	<td colspan="5" bgcolor="#99CC66" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr bgcolor="#99CC66">
	  <td colspan="5" id="dateformat" height="20">  <script language="JavaScript" type="text/javascript">
	  document.write(TODAY);	</script>	</td>
  </tr>
  <tr>
	<td colspan="5" bgcolor="#99CC66" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr>
	<td colspan="5" bgcolor="#5C743D"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

 <tr>
	<td width="173" height="671" valign="top" bgcolor="#5C743D">
	<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
		<tr>
		  <td width="165"> <br />
		  <br /></td>
		</tr>
		<tr>
		  <td width="165"><a href="index.html" class="navText">Home</a></td>
		</tr>
		<tr>
		  <td width="165"><a href="sobreemp.html" class="navText">Sobre a Empresa</a></td>
		</tr>
		<tr>
		  <td width="165"><a href="faleconosco.html" class="navText">Fale Conosco</a></td>
		</tr>
		<tr>
		  <td width="165"><a href="java script:;" class="navText">Estatisticas</a></td>
		</tr>
		<tr>
		  <td width="165"><a href="java script:;" class="navText">Listas de Serviços</a></td>
		</tr>
		<tr>
		  <td width="165"><a href="newcadcurriculo.html" class="navText">Trabalhe Conosco</a></td>
		</tr>
		<tr>
		  <td height="35"><a href="java script:;" class="navText">Area Restrita</a></td>
		</tr>
		<tr>
		  <td height="156">
		  <center><iframe src="http://tempoagora.uol.com.br/selos/custom/selo_3dias.php?cid=Acegua-RS,Bage-RS,ColoniaNova-RS,HulhaNegra-RS,Candiota-RS,DomPedrito-RS,Pelotas-RS,PortoAlegre-RS,SaoGabriel-RS,LavrasdoSul-RS,&height=155&cor=" name="tempoagora_custom_3dias" width="149" marginwidth="0" height="155" marginheight="0" scrolling="No" frameborder="0" id="tempoagora_custom_3dias"></iframe></center></td>
		</tr>
	  </table>
 	 <br />
	   <br />
	   <br />
	   <br /> 	</td>
	<td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
	<td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
	 <label></label>
<br />
	 <br /> 
	<br />
	 <img src="mm_spacer.gif" alt="" width="50" height="1" border="0" />
	<table width="315" border="1" align="center">
	  <caption align="top" class="subHeader">
		Menu de Acesso
		</caption>
	  <tr>
		<th width="235" scope="col"><div align="left">Lista Curriculos cadastrados</div></th>
		<th width="64" class="smallText" scope="col"><label><a href="listcurriculo.php">Listar</a></label></th>
		</tr>
	  <tr>
		<th scope="col"><div align="left">Lista Fale Conosco</div></th>
		<th class="smallText" scope="col"><label>Listar
		  
		</label></th>
		</tr>
	</table>
	<br />	</td>
	<td width="12"> </td>
  </tr>

  <tr>
	<td width="173" height="142"> </td>
	<td width="50"> </td>
	<td width="5"> </td>
	<td width="755"> </td>
	<td width="12"> </td>
  </tr>
</table>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.