SHARE
TWEET

Untitled

a guest Sep 4th, 2018 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $usuario = $_SESSION['username'];
  3.     $pass = $_SESSION['password'];
  4.  
  5.     $results = $mysqli->query("SELECT Nombre, SUBSTRING(Nombre, 1,20) AS palabra,
  6.                               IdUsuario, Username, Password
  7.                               FROM Usuarios
  8.                               WHERE Username='$usuario' AND Password ='$pass'");
  9.     mysqli_set_charset("utf8");
  10.     if($res = $results->fetch_array()) {}
  11.  
  12.     ?>
  13.    
  14. <?php
  15. /* Evitamos inyección SQL */
  16. $usuario = $mysqli->real_escape_string($_SESSION['username']);
  17. $pass = $mysqli->real_escape_string($_SESSION['password']);
  18. /* Cambiamos a UTF-8 *ANTES* de hacer consultas SQL */
  19. $mysqli->set_charset("utf8");
  20.  
  21. /* Realizamos la consulta SQL */
  22. $results = $mysqli->query("
  23.   SELECT
  24.     Nombre,
  25.     SUBSTRING_INDEX(Nombre, ' ', 1) palabra,
  26.     IdUsuario,
  27.     Username,
  28.     Password
  29.   FROM Usuarios
  30.   WHERE Username='$usuario' AND Password ='$pass'
  31. ");
  32. if($res = $results->fetch_array()) {
  33.     /* Aquí se supone que haces lo necesario con $res['palabra'] */
  34. }
  35. ?>
  36.    
  37. <?php
  38. $usuario = $_SESSION['username'];
  39. $pass = $_SESSION['password'];
  40.  
  41. $results = $mysqli->query("SELECT Nombre, SUBSTRING(Nombre, 1,20) AS palabra,
  42.                           IdUsuario, Username, Password
  43.                           FROM Usuarios
  44.                           WHERE Username='$usuario' AND Password ='$pass'");
  45. mysqli_set_charset("utf8");
  46.  
  47. while($row = $result->fetch_assoc()) {
  48.     echo explode(" ",$row['Nombre'])[0];
  49. }
  50.  
  51. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top