Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. public function registrar($username, $email, $password, $confirm_password)
  2. {
  3. try
  4. {
  5. $this->has = crypt($password);
  6. $this->has_con = crypt($confirm_password);
  7. $p= "soy diferente de uno";
  8.  
  9. $registro = $this->conexion->conexion->query("insert into registro_por (nombre, correo, pass, conf_pass) values( '$username', '$email', '$this->has', '$this->has_con')");
  10.  
  11. if ($registro)
  12. {
  13. return $p;
  14. }
  15. else
  16. {
  17. throw new Exception("Fallos la ejecución");
  18. }
  19.  
  20.  
  21. }
  22. catch (Exception $e)
  23. {
  24. echo 'Message: '.$e->getMessage();
  25. }
  26. }
  27.  
  28. require_once("../Model/registro.php");
  29.  
  30. $username = $_POST["username"];
  31. $email = $_POST["email"];
  32. $password = $_POST["password"];
  33. $confirm_password = $_POST["confirm_password"];
  34.  
  35. $reg = new Registro();
  36. $t = $reg->registrar($username, $email, $password, $confirm_password);
  37.  
  38. var_dump($t);
  39.  
  40. if ($t != 1)
  41. {
  42. //return "ok";
  43. //echo "es difenrete de uno";
  44. return $t;
  45. }
  46. else
  47. {
  48. return $t;
  49. //echo "fail";
  50. }
  51.  
  52. $('#register-submit').click(function () {
  53.  
  54. var data = $('#register-form').serialize();
  55.  
  56. $.ajax({
  57. beforeSend: function () {
  58. console.log(data);
  59. },
  60. type: 'POST',
  61. url: '../Controllers/registro.php',
  62. data: data,
  63. success: function (data) {
  64. console.log('nanananana');
  65. console.log("soy data"+data);
  66. }
  67. });
  68.  
  69. });
  70.  
  71. error: function (xhr) {
  72. console.log(xhr.responseText);
  73. }
  74.  
  75. $.ajax({
  76. beforeSend: function () {
  77. console.log(data);
  78. },
  79. type: 'POST',
  80. url: '../Controllers/registro.php',
  81. data: data,
  82. //Cargando, le agregas un gif a un div
  83. beforeSend: function () {
  84. console.log("cargando")
  85. },
  86. success: function (data) {
  87. console.log('nanananana');
  88. console.log("soy data"+data);
  89. },
  90. //Error que mostrará desde PHP
  91. error: function (xhr) {
  92. console.log(xhr.responseText);
  93. }
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement