Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/03/2011, 20:49
nuevoconphp
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 3
Pregunta sesion con e-mail

Ok, hize un sistema para sesiones, funciona perfecto siempre y cuando no utililize una direccion e-mail como el nombre asignado para el usuario, en otras palabras por ejemplo si utilizo "[email protected]" como usuario con su respectiva contraseña no reconoce este nombre de usuario y no me inicia la sesion, de lo contrario si uso solo "juancito" como nombre de usuario con su respectiva contraseña me inicia la sesion perfectamente, estoy seguro q tiene q ver con el @ y los puntos de la direccion de e-mail. Alguien tiene idea porque pasa esto, tiene q ver con el codigo php o la estructura de mi tabla de usuarios en mysql?

muchas gracias


este es el script que estoy utilizando:

Código:
<?php require_once('CONECCION'); ?>
<?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
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['usuario'])) {
  $loginUsername=$_POST['usuario'];
  $password=$_POST['pass'];
  $MM_fldUserAuthorization = "nivel_acceso";
  $MM_redirectLoginSuccess = "after_login.php";
  $MM_redirectLoginFailed = "login_fallido.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_IBC, $IBC);
  	
  $LoginRS__query=sprintf("SELECT e_mail_usuario, pass_usuario, nivel_acceso FROM adminis WHERE e_mail_usuario=%s AND pass_usuario=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $IBC) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'nivel_acceso');
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    $_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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administración IBC</title>


</head>
<body>
	<div id="principal">
	  <div align="center">
	    <div id="wraping">
	      <form ACTION="<?php echo $loginFormAction; ?>"  class="jqtransform"  method="POST" id="loging">
	      <div id="apDiv2">
	        <div id="apDiv3">
	          <div id="apDiv4">
	            <div id="admin-cabez">
                Administración IBC</div>
	            <p class="loging">
                <br />
	            <br />
	            <input name="usuario" type="text" class="validate[required]" id="usuario" />
	            <img name="" src="../../principal/images/trans.png" width="20" height="10" alt="" />Usuario (e-mail) 
                <br />
	            <br />
	            <input type="password" name="pass" id="pass" class="validate[required]"/>
	            <img name="" src="../../principal/images/trans.png" width="20" height="10" alt="" />Contraseña 
                <br />	              
                <br />
	            <input name="submit" type="submit" class="jqTransformButton" id="submit" value="Aceptar" />
                </p>
              </div>
	        </div>
	      </div>
	      </form>
	    </div>
	  </div>
	</div>
</body>
</html>