Ir para conteúdo

POWERED BY:

Arquivado

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

Lucas-5281

Erro --> Unknown column 'login123' in 'where clause&#3

Recommended Posts

Boa tarde amigos!!! Criei um sistema de login com o dreamweaver e esta acontecendo o seguinte problema, quando eu crio um login só com números sem letras (ex: login: 123 senha: 123) O login é feito sem nenhum erro, mas quando eu crio um login com letras e numeros ou só com letras (ex: login: log123 senha: 123) aparece esse erro: Unknown column 'login123' in 'where clause' Já refiz o sistema de login mas mesmo assim aparece esse erro. O que pode ser?

Obrigado...

<?php 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['user'])) {
  $loginUsername=$_POST['user'];
  $password=$_POST['senha'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "login.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_config, $config);
  
  $LoginRS__query=sprintf("SELECT `user`, senha FROM area_cliente WHERE `user`=%s AND senha=%s",
    GetSQLValueString($loginUsername, "-1"), 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">
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sem título</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <table width="683" border="0" align="center" style="margin-top:200px;">
    <tr>
      <td colspan="3" style="font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:24px; color:#03F;"><p>ACESSO / AREA DO CLIENTE</p>
      <p> </p></td>
    </tr>
    <tr>
      <td style="font-family:Arial, Helvetica, sans-serif; font-weight:bold;"> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td width="154" style="font-family:Arial, Helvetica, sans-serif; font-weight:bold;">User do login :</td>
      <td width="10"> </td>
      <td width="514"><label for="user"></label>
        <span id="sprytextfield1">
        <input type="text" name="user" id="user" />
      <span class="textfieldRequiredMsg" style="font-family:Arial, Helvetica, sans-serif;">É necessário informar o user de seu login </span></span></td>
    </tr>
    <tr>
      <td style="font-family:Arial, Helvetica, sans-serif; font-weight:bold;">Senha do login :</td>
      <td> </td>
      <td><label for="senha"></label>
        <span id="sprytextfield2">
        <input type="password" name="senha" id="senha" />
      <span class="textfieldRequiredMsg" style="font-family:Arial, Helvetica, sans-serif;">É necessário informar a senha de seu login </span></span></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td><input name="botao" type="submit" class="botao" id="logar" value="ENTRAR" />


</td>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form>
<p> </p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});
</script>
</body>
</html> 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Meu Deus do Céu, ainda tem gente que usa estas M%$CS_CFS*(FDS&FSFS* de código gerado pelo DW :assobiando:

 

Em todo caso coloque entre aspas simples o formato

WHERE `user` = '%s' AND senha= '%s'
SELECT `user`, `senha` FROM area_cliente WHERE `user`='%s' AND senha='%s'

Compartilhar este post


Link para o post
Compartilhar em outros sites

Boa tarde!!! Fiz como você disse mais esta acontecendo o seguinte erro:

 

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'login852''' at line 1

Compartilhar este post


Link para o post
Compartilhar em outros sites

Analisando a função teria que passar o login na função como text, e não default

 

$LoginRS__query=sprintf("SELECT `user`, `senha` FROM `area_cliente` WHERE `user` = '%s' AND `senha` = '%s'",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

Troque este trecho de código acima pelo que foi gerado, e abandona esta pratica, ninguém da suporte a este lixo gerado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agora esta dando esse erro: :unsure:

 

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'login852'' AND `senha` = ''852''' at line 1

Compartilhar este post


Link para o post
Compartilhar em outros sites

é o seguinte, na sua função insere aspas simples

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

remova da query

SELECT `user`, `senha` FROM `area_cliente` WHERE `user` = %s AND `senha` = %s

Acredito que seja o tipo de parâmetro passado antes como "-1", estava dando problema, testa ai

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.