Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/02/2010, 16:11
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Pregunta Conectar usuario

Hola a todos, este es mi primer post, me dijeron que este es el mejor foro de php que existe...xD

Mi problema es que he creado , con dreamweaver, el siguiente codigo para loguear usuarios , pero no funciona y me dá el siguiente error:

Unknown column 'fulanito' in 'where clause'

Donde fulanito seria el nombre de usuario que ingresó el usuario.
Lo probé en mi pc con xampp y en un servidor remoto y no funciona.
La coneccion a la base está perfecta.
La tabla en la base y los campos, están creados.
He creado un archivo llamado bien.php para que se dirija si inicia sesion de manera satisfactoria , y otro llamado mal.php si es incorrecto.
Solos esos son los archivos y tambien está el de la coneccion.php.

SI ALGUIEN ME AYUDA SE LO AGRADECERÉ
SALUDOS AMIGOS

Código PHP:
<?php require_once('Connections/coneccion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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['password'];
  
$MM_fldUserAuthorization "";
  
$MM_redirectLoginSuccess "bien.php";
  
$MM_redirectLoginFailed "mal.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_coneccion$coneccion);
  
  
$LoginRS__query=sprintf("SELECT `user`, password FROM `admin` WHERE `user`=%s AND password=%s",
    
GetSQLValueString($loginUsername"-1"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$coneccion) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
     
$loginStrGroup "";
    
    
//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 );
  }
}
?>
Código HTML:
<!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>Documento sin t&iacute;tulo</title>
</head>

<body>
<form ACTION="<?php echo $loginFormAction; ?>" id="usuarios" name="usuarios" method="POST">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="5">
        <tr>
          <td>Usuario</td>
          <td><input type="text" name="user" id="user" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input type="password" name="password" id="password" /></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><label for="limpiar">limpiar</label>
            <input type="reset" name="limpiar" id="limpiar" value="Restablecer" />
          <input type="submit" name="button" id="button" value="Iniciar sesion" /></td>
        </tr>
  </table>
</form>
</body>
</html>