Advertisement
Guest User

new $("#btn").click(function(){ if ($('#p

a guest
Jul 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. $("#btn").click(function(){
  2. if ($('#password').val() == $('#password_again').val()) {
  3. $.post("reg.php", {
  4. first_name: $('#first_name').val(),
  5. name: $('#name').val(),
  6. avatar: img,
  7. username: $('#username').val(),
  8. password: $('#password').val(),
  9. password_again: $('#password_again').val(),
  10. mail: $('#mail').val()
  11. },
  12. function (res) {
  13. alert(res.done);
  14. window.location.href = document.location.origin + res.url;
  15. }
  16. );
  17. } else {
  18. alert("Пароли не совпадают!");
  19. window.location.href = document.location.origin + "/reg.php";
  20. }
  21. });
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. reg.php
  30. ....
  31. else {
  32. mysqli_query($con, "INSERT INTO users (avatar, mail, first_name, name, username, password) VALUES ('" . $avatar . "','" . $mail . "','" . $first_name . "','" . $name . "','" . $username . "', '" . md5($password) . "')");
  33. echo json_encode(array('done' => 'Вы зарегистрированы!', 'url' => '/home.php'));
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement