El código es:
Código PHP:
Ver original
<?php $db_host = 'localhost'; $db_user = '**********'; $db_pass = '*********'; $db_name = '********'; // ACCESO VIA COOKIE { $cookie_user = $cookie[0]; $cookie_id = $cookie[1]; $cookie_ip = $cookie[2]; if ($HTTP_X_FORWARDED_FOR == "") { } else { } if ($cookie_ip == $ip) { { $_SESSION["session_username"] = $row['username']; $_SESSION["session_logeado"] = "SI"; } } } if ($_GET["action"] == 'entrar') { function error($e){ echo $e'; } // Conectar a la base de datos $db_link = mysql_connect($db_host, $db_user, $db_pass); mysql_select_db($db_name, $db_link) or die("Error: " . mysql_error()); if ($_POST['username']) { //Comprobacion del envio del nombre de usuario y password $username = htmlentities(trim($_POST['username'])); $password = md5($_POST['password']); if ($password == NULL) { error("No a introducido una contrasenia"); } else { $sql = sprintf("SELECT username,password FROM usuarios WHERE username='%s'", mysql_real_escape_string($username)); $db_query = mysql_query($sql, $db_link) or die("Error: " . mysql_error()); $data = mysql_fetch_array($db_query); if ($data['password'] != $password) { error("Email o password incorrectos"); } else { $sql = sprintf("SELECT username,password FROM usuarios WHERE username='%s'", mysql_real_escape_string($username)); $db_query = mysql_query($sql, $db_link) or die("Error: " . mysql_error()); $row = mysql_fetch_array($db_query); $username2 = $row['username']; $_SESSION["session_username"] = $row['username']; $_SESSION["session_logeado"] = "SI"; if ($_POST['recordar']) { if ($HTTP_X_FORWARDED_FOR == "") { $ip = getenv(REMOTE_ADDR); } else { $ip = getenv(HTTP_X_FORWARDED_FOR); } $id_extreme = md5(uniqid(rand(), true)); $id_extreme2 = $username2."%".$id_extreme."%".$ip; setcookie('id_extreme', $id_extreme2, time()+7776000, '/'); $sql = sprintf("UPDATE usuarios SET id_extreme='%s' WHERE username='%s'", mysql_real_escape_string($id_extreme), mysql_real_escape_string($username2)); $query = mysql_query($sql, $db_link) or die("Error: " . mysql_error()); } echo ""; } } } } ?></p> <?php if ($_SESSION["session_logeado"] == "SI") { ?> Bienvenido <?php echo $_SESSION['session_username']; ?> <?php } else { ?> <table width="69%" border="0" style="margin-bottom: 16px"> <form method="post" action="login.php"> <tr> <td width="6%" height="40"><p><img src="<?=$statics?>u2.png" width="32" height="32" /></p></td> <td width="35%"><input name="username" type="text" id="username" placeholder="Username/nick" size="100" /></td> <td width="7%"><img src="<?=$statics?>u1.png" width="32" height="32" /></td> <td width="39%"><input name="password" type="password" id="password" placeholder="Password" size="100" /></td> <td width="13%"><p> <input type="button" value="Entrar" /> </p></td> </tr> <tr> <td height="21"> </td> <td height="21" colspan="2"><h4> <input type="checkbox" name="recordar" /> Recordarme</h4></td> <td height="21" colspan="2"><a href="gg">Perdí mi contraseña</a> | <a href="<?=$url?>signup">Registrate</a></td> </tr> </form> </table> <?php } ?>
Espero que puedan ayudarme, no encuentro el error

Saludos!