Ver Mensaje Individual
  #57 (permalink)  
Antiguo 14/05/2010, 01:23
Avatar de Flow89
Flow89
 
Fecha de Ingreso: abril-2010
Ubicación: Valladolid
Mensajes: 346
Antigüedad: 14 años
Puntos: 1
Respuesta: Seguridad en PHP [Importante];

Ok, gracias, Modificaré mis HTTP_POST_VARS por $_POST

Respecto a el codigo Heli0s aqui lo tienes;

Código PHP:
 <html>
<head>
<title>JuventudMDC - Panel de Administraci&oacute;n</title>
<link href="../css/general.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
   
include("conex.php");
   include(
"segu.php");

$nick mysql_real_escape_string($HTTP_POST_VARS["nick"]);
$password mysql_real_escape_string($HTTP_POST_VARS["password"]);
echo 
"$password";

 
  if(
trim("$nick") != "" && trim("$password") != "");
  {
$nickN mysql_real_escape_string($nickN);
$passN mysql_real_escape_string($passN);
$nickN htmlentities($nick);
$passN htmlentities($password);


  
$result mysql_query("SELECT password FROM usuarios WHERE nick='$nickN'");
  if(
$row mysql_fetch_array($result))
   {
  if(
$row["password"] == $passN)
  {
  
//La cookie dura 1 hora
  
setcookie("usNick",$nickN,time()+36000);
  
setcookie("usPass",$passN,time()+36000);
  echo 
"<table style=\"height:100%;width:100%;\" border=\"0\"><tr><td class=\"estilo34\"><div align=\"center\">Logueado correctamente, ahora sera dirigido a el panel de administración automaticamente.</div></td></tr></table>";
  echo 
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; url=administracion.php\">";
  }
  else
  {
  echo 
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; url=../panel.php\">";
  echo 
"<table style=\"height:100%;width:100%;\"border=\"0\"><tr><td class=\"estilo34\"><div align=\"center\"><br>Contraseña incorrecta. <br> Seras redireccionado automaticamente.</div></td></tr></table>";
  }
  }
  else
  {
  echo 
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; url=../panel.php\">";
  echo 
"<table style=\"height:100%;width:100%;\"border=\"0\"><tr><td class=\"estilo34\"><div align=\"center\"><br>Ese Usuario no existe en la base de datos. <br> Seras redireccionado automaticamente.</div></td></tr></table>";
  }
  
mysql_free_result($result);
  }
  else
  {
  echo 
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; url=../panel.php\">";
  echo 
"<table style=\"height:100%;width:100%;\"border=\"0\"><tr><td class=\"estilo34\"><div align=\"center\"><br>Debe especificar un nick y password. <br> Seras redireccionado automaticamente.</div></td></tr></table>";
  }
  
mysql_close();  
  
?> 
</body>
</html>

Todo a pasado a raiz de meter el campo contraseña por un mysql_real_escape_string, que no reconocia la contraseña como valida aún estando bien.

PD:Te conteste en el post de HTML y CSS, te puse los codigos, jeje.

Última edición por Flow89; 14/05/2010 a las 01:35