Foros del Web » Programando para Internet » PHP »

como integrar la funcion md5()

Estas en el tema de como integrar la funcion md5() en el foro de PHP en Foros del Web. tengo un sistema de registro muy simple pero no consigo añadirle la función de encriptación md5 a la contraseña donde debería de ir esa función ...
  #1 (permalink)  
Antiguo 25/06/2014, 10:27
Avatar de losaudiolibros  
Fecha de Ingreso: abril-2011
Mensajes: 69
Antigüedad: 13 años
Puntos: 0
como integrar la funcion md5()

tengo un sistema de registro muy simple pero no consigo añadirle la función de encriptación md5 a la contraseña donde debería de ir esa función exactamente ?
Código 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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO indentifica (usuario, contrasena, nivel) VALUES (%s, %s, %s)",
                       
GetSQLValueString($_POST['usuario'], "text"),
                       
GetSQLValueString($_POST['contrasena'], "text"),
                       
GetSQLValueString($_POST['nivel'], "int"));
  
mysql_select_db($database_basic$basic);
  
$Result1 mysql_query($insertSQL$basic) or die(mysql_error());
 
  
$insertGoTo "registrado.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

?>
__________________
www.LosAudioLibros.eshttp://www.losaudiolibros.es
correo [email protected]
  #2 (permalink)  
Antiguo 25/06/2014, 10:33
 
Fecha de Ingreso: julio-2008
Mensajes: 56
Antigüedad: 15 años, 9 meses
Puntos: 2
Sonrisa Respuesta: como integrar la funcion md5()

Intenta con

Código:
md5($_POST['contrasena'])
en lugar de

Código:
$_POST[md5('contrasena')]
  #3 (permalink)  
Antiguo 25/06/2014, 10:36
Avatar de losaudiolibros  
Fecha de Ingreso: abril-2011
Mensajes: 69
Antigüedad: 13 años
Puntos: 0
Respuesta: como integrar la funcion md5()

me funciona perfecto mil gracias toda las tarde probando jejeje
__________________
www.LosAudioLibros.eshttp://www.losaudiolibros.es
correo [email protected]
  #4 (permalink)  
Antiguo 25/06/2014, 10:39
 
Fecha de Ingreso: julio-2008
Mensajes: 56
Antigüedad: 15 años, 9 meses
Puntos: 2
Respuesta: como integrar la funcion md5()

ok. puedes ponerle Resuelto entonces.

Saludos. (Y)
  #5 (permalink)  
Antiguo 25/06/2014, 12:22
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Respuesta: como integrar la funcion md5()

Al momento de recuperar la contrasena debes hacerle un md5() y comparar con la que tienes almacenada y cifrada (porque obviamente la almacenas cifrada)

El problema con md5() es que se rompe MUY facil........ investiga que PHP viene con otras funciones de HASH
__________________
Salu2!

Etiquetas: encriptacion, md5, registro
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 13:35.