Guest User

Untitled

a guest
Dec 18th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. if(true && true){}
  2.  
  3. include "../class/class.conexion.php";
  4. include "define.urls.php";
  5.  
  6. $db = new Conexion();
  7.  
  8. if (isset($_POST["name"])) {
  9. $name = $_POST["name"]; // Nombre real del usuario
  10. $username = $_POST["username"]; // Nombre de usuario o nickname
  11. $email = $_POST["email"]; // Email del usuario
  12. $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // ContraseƱa del usuario
  13.  
  14. $imagen_de_perfil = website_images."/profile-image-lyrians.png"; // Imagen de perfil por defecto
  15. $imagen_de_portada = website_images."/profile-cover-lyrians.png";
  16. $rango = "novato"; // Rango inicial del usuario
  17. $descripcion = NULL;
  18. $confirmacion = "no confirmado";
  19.  
  20. // Notification
  21. $id_notification = NULL;
  22. $notificacion = htmlentities("http://unapagina.com;Gracias por formar parte de esta comunidad;Te recomiendo leer este post");
  23. $time = time(); // Tiempo exacto de la notificacion
  24. $idAdmin = 1;
  25.  
  26. // Verifico si en la tabla users no hay ningun usuario con el mismo EMAIL o USERNAME
  27. if ($verify = $db->prepare("SELECT username, email FROM users WHERE username = ? OR email = ?")) {
  28. $verify->bind_param("ss", $username, $email);
  29. $verify->execute();
  30. $verify->store_result();
  31. $verify->bind_result($username, $email);
  32.  
  33. if ($verify->num_rows > 0) {
  34. echo "0";
  35.  
  36. $verify->close();
  37. } else{
  38. $user = $db->prepare("INSERT INTO users (user_image,
  39. user_cover_page,
  40. username,
  41. user_description,
  42. email,
  43. password,
  44. name,
  45. rango,
  46. email_confirmation,
  47. user_register_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  48.  
  49. $notification = $db->prepare("INSERT INTO notifications (notification_user,
  50. notification_send_user,
  51. notification_title,
  52. notification_datetime) VALUES (?, ?, ?, ?)");
  53.  
  54. $user->bind_param("sssssssssi", $imagen_de_perfil,
  55. $imagen_de_portada,
  56. $username,
  57. $descripcion,
  58. $email,
  59. $password,
  60. $name,
  61. $rango,
  62. $confirmacion,
  63. $time);
  64.  
  65. if ($user->execute()) {
  66. $userID = $user->insert_id;
  67. $notification->bind_param("iisi", $userID, $idAdmin, $notificacion, $time);
  68.  
  69. if ($notification->execute()) {
  70. echo "1";
  71. } else{
  72. echo "notification";
  73. }
  74.  
  75. $user->close();
  76. $notification->close();
  77. }
  78. }
  79. } else{
  80. echo $db->error;
  81. }
  82. }
Add Comment
Please, Sign In to add comment