• 0
Sign in to follow this  
mestre fyoda

Session

Question

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tibia/public_html/loga.php on line 20

essa é a linha 20 .

           session_start();
           $_SESSION["usuario"] = "$dados['login']";

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

não deu certo ,

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/tibia/public_html/login.php:8) in /home/tibia/public_html/login.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/tibia/public_html/login.php:8) in /home/tibia/public_html/login.php on line 61

aqui é a linha 19

<?
session_start();
echo $_SESSION["usuario"];
if(!session_is_registered("usuario")) {
?>
linha 61
<?
}
if(session_is_registered("usuario")) {
   header("Location: page.php");
}
?>

Share this post


Link to post
Share on other sites
  • 0

Warning: Cannot modify header information - headers already sent by (output started at /home/tibia/public_html/login.php:13) in /home/tibia/public_html/login.php on line 60

a linha 60 esta la em baixo , é essa parte

  header("Location: page.php");
esse é o meu codigo , login.php
<?
session_start();
$_SESSION["usuario"];
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Login - Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="mural/templates/default/mural.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
	font-size: 14px;
	font-weight: bold;
}
-->
</style>
</head>


  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E8E8E8" class="tabela3">
    <tr> 
      <td width="156"><div align="right"><font size="3" face="Verdana, Arial"><br>
          <img src="fundo/login.gif" width="97" height="105"><br>
          </font> </div></td>
      <td width="342"><div align="center"><span class="style1">Área para Assinantes</span><br>
          <font color="#FF0000"><b>
<?	
if($_GET['login'] == "falhou") {
    echo"  Erro: ".$_GET['causa']." ";
}
?>
<form  method="post" action="loga.php?acao=logar">

</b></font><br>
          Usuário:<br>
          <input name="login" type="text" class="campos"  maxlength="10">
          <br>
          Senha:<br>
          <input name="senha" type="password" class="campos" maxlength="10">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center"><br>
        </div></td>
      <td><div align="center"> 
          <input name="Submit" type="submit" class="botao" value="Entrar">
          <br>
          <br>
        </div></td>
    </tr>
  </table>
</form>

<?
if(session_is_registered("usuario")) {
   header("Location: page.php");
}
?>
</html>

Share this post


Link to post
Share on other sites
  • 0
Guest Guest

esse é um dos codigos que se usa session , me corrijam se tiver algo errado .

<?
ob_start();


if($acao == "logar") {

include "config.php";
   
   $login = $_POST['login'];
   $q_user = mysql_query("SELECT * FROM cadastros WHERE login='$login'");

   if(mysql_num_rows($q_user) == 1) {
   
       $query = mysql_query("SELECT * FROM cadastros WHERE login='$login' ");
       $dados = mysql_fetch_array($query);
       
  if($_POST['senha'] == $dados['senha'] and $dados['ativo'] == 'sim') {
           session_start();
           $_SESSION["usuario"] = $dados['login'];
           header("Location: index.php");
           exit;

         } if($_POST['senha'] != $dados['senha']) {
           header("Location: login.php?login=falhou&causa=".urlencode('Senha Errada'));
           exit;
       }

    if($dados['ativo'] != 'sim') {
           header("Location: login.php?login=falhou&causa=".urlencode('Usuario não ativo'));
           exit;
       }	

   } else {
       header("Location: login.php?login=falhou&causa=".urlencode('User Inválido'));
       exit;
     }
   }


if(!session_is_registered("usuario")) {
   header("Location: index.php");
}

?>

<?
ob_end_flush();
?>

Share this post


Link to post
Share on other sites
  • 0

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/tibia/public_html/login.php:8) in /home/tibia/public_html/login.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/tibia/public_html/login.php:8) in /home/tibia/public_html/login.php on line 61

1º - você sempre que usar session deve ter no inicio da pagina :

Session_start();

2º - não use o comando header(); antes dele não pode ter nehuma saida HTML.

user JS é melhor.

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
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