Foros del Web » Programando para Internet » PHP »

consulta md5

Estas en el tema de consulta md5 en el foro de PHP en Foros del Web. Tengo un script para comprobar si usuario y contraseña, intento agregarle md5 pero me arroja algunos errores , que hacen referencia a la funcion para ...
  #1 (permalink)  
Antiguo 05/12/2012, 13:18
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 3 meses
Puntos: 61
consulta md5

Tengo un script para comprobar si usuario y contraseña, intento agregarle md5 pero me arroja algunos errores , que hacen referencia a la funcion para evitar la inyeccion de sql:

Código PHP:
$query_login sprintf("SELECT    tb_usuario.usuario, tb_usuario.password, tb_usuario.ip    
                        FROM tb_usuario WHERE usuario = %s AND password = %s"
,
                        
GetSQLValueString($_POST['usuario'], "text"),
                        
GetSQLValueString(md5($_POST['password'], "text"))); 
y esta es mi otra funcion para evitar la inyeccion de sql .

Código 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;
    }


Saludos
  #2 (permalink)  
Antiguo 05/12/2012, 13:22
Avatar de Reedyseth  
Fecha de Ingreso: enero-2009
Ubicación: Chihuahua, México
Mensajes: 419
Antigüedad: 15 años, 2 meses
Puntos: 36
Respuesta: consulta md5

Tal vez puedes usar PDO lingando(Binding) los valores, PDO ya viene preparado para evitar la inyección y solo tienes que usar en enlace de datos.
  #3 (permalink)  
Antiguo 05/12/2012, 13:26
Avatar de Ribon  
Fecha de Ingreso: septiembre-2010
Ubicación: El firmamento
Mensajes: 487
Antigüedad: 13 años, 7 meses
Puntos: 91
Respuesta: consulta md5

En la siguiente linea

Código PHP:
Ver original
  1. GetSQLValueString(md5($_POST['password'], "text")));

estás mándandolo el parámetro "text" a la función md5

cambiala por esto

Código PHP:
Ver original
  1. GetSQLValueString(md5($_POST['password']), "text"));

saludos.
__________________
Utilice el Highlight para mostrar código, mis ojos se lo agradecerán :)
qué es esto? :O -> http://i48.tinypic.com/5x3kzs.png
Ya sabes :)
  #4 (permalink)  
Antiguo 05/12/2012, 13:38
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 3 meses
Puntos: 61
Respuesta: consulta md5

Muchas gracias por sus comentarios Ribon funciono perfecto! , Reedyseth en el futuro empezare a utilizar PDO en mis nuevos proyectos.

Saludos

Etiquetas: md5, mysql, sql, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:03.