Guest User

Untitled

a guest
Jan 15th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['usuario'])) {
  4. header('Location: personajes');
  5. exit();
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <html lang="es">
  10. <head>
  11. <title>Iniciar sesión en United States Roleplay</title>
  12. <meta charset="UTF-8">
  13. <meta name="viewport" content="width=device-width, initial-scale=1">
  14. <link rel="stylesheet" type="text/css" href="css/login.css">
  15. </head>
  16. <body>
  17. <div class="wrapper fadeInDown">
  18. <div id="formContent">
  19. <h2 class="active"> Ingresar </h2>
  20. <a href="registrarme/index.php">
  21. <h2 class="inactive underlineHover"> Registrarme </h2>
  22. </a>
  23. <div class="fadeIn first">
  24. <img src="images/logo.jpg" id="icon" alt="User Icon" />
  25. </div>
  26. <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
  27. <p id="error" style="color:#B22222"></p>
  28. <input type="text" id="login" class="fadeIn second" name="usuarioingresado" placeholder="Escribe tu usuario o e-mail">
  29. <input type="password" id="password" class="fadeIn third" name="contraingresada" placeholder="Escribe tu contraseña">
  30. <input type="submit" class="fadeIn fourth" value="Entrar">
  31. </form>
  32. <div id="formFooter">
  33. <a class="underlineHover" href="recuperar">¿Has olvidado tu contraseña?</a>
  34. </div>
  35. </div>
  36. </div>
  37. </body>
  38. </html>
  39.  
  40. <?php
  41. include 'scripts/conexion.php';
  42. if($_POST){
  43. $arrDatos=array();
  44. $arrDatos['usr'] = (!empty($_POST['usuarioingresado']) ) ? array ('data'=>$_POST['usuarioingresado']) : array('id'=> 1, 'msg'=>'Debes poner un usuario o un e-mail.');
  45. $arrDatos['pwd'] = (!empty($_POST['contraingresada']) ) ? array ('data'=>$_POST['contraingresada']) : array('id'=> 1, 'msg'=>'Debes poner una contraseña.');
  46. if(array_column($arrDatos, 'msg')) {
  47. $msgs=implode("<br />",array_column($arrDatos, 'msg'));
  48. echo "<script>document.getElementById('error').innerHTML = '".$msgs."'</script>";
  49. } else {
  50. $ce = strtoupper( hash('whirlpool', $arrDatos['pwd']['data']) );
  51. $lp = array(" ", "-","DROP", "TABLE", "SELECT", "INSERT", "VALUES", "FROM", "INTO", "CREATE", "SET", "SQL", "PDO", "$", "DELETE", "UPDATE", "'", "=", ";");
  52. $u=$arrDatos['usr']['data'];
  53. $ul = str_replace($lp, "", $u);
  54. $c=$arrDatos['pwd']['data'];
  55. $bR = "SELECT * FROM sv_nicks WHERE Nick = '$ul' or Email = '$el' and Contra = '$ce'";
  56. $r = $con->query($bR);
  57. $c1 = mysqli_num_rows( $r );
  58. if( $c1 === 1 ){
  59. session_start();$_SESSION['usuario'] = $ul; header("Location: personajes");
  60. }else{
  61. echo "<script>document.getElementById('error').innerHTML = 'Los datos de inicio de sesión son incorrectos.'</script>";
  62. }
  63. }
  64. }
  65. ?>
Add Comment
Please, Sign In to add comment