Guest User

Untitled

a guest
Apr 23rd, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. <form action="includes/register.php" class="form__signup" id="register-form" method="POST">
  2. <a href="" class="reg-close"></a>
  3. <div class="form__header">
  4. <h2 class="form__title">Регистрация</h2>
  5. </div> <!-- ====== form__header ====== -->
  6. <div class="form__msg" class="msgs"></div>
  7. <div class="form__group">
  8. <input type="text" class="form__control" placeholder="Ваше имя" name="full_name" id="full_name" />
  9. </div>
  10. <div class="form__group">
  11. <input type="email" class="form__control" placeholder="Ваш Email" name="email" id="email">
  12. </div>
  13. <div class="form__group">
  14. <input type="text" class="form__control" placeholder="Ваш логин" name="username" id="username">
  15. </div>
  16. <div class="form__group">
  17. <input type="password" class="form__control" placeholder="Ваш пароль" name="password" id="password" />
  18. </div>
  19. <div class="form__group">
  20. <input type="password" class="form__control" placeholder="Подтвердите пароль" name="cpassword" id="cpassword" />
  21. </div>
  22. <div class="form__group">
  23. <button type="submit" class="form__btn" name="do-signup" id="btn-submit">Регистрация</button>
  24. </div>
  25. </form>
  26.  
  27. require_once 'connection.php';
  28.  
  29. if(isset($_POST["do-signup"])){
  30.  
  31.  
  32. if(!empty($_POST['full_name']) && !empty($_POST['email']) && !empty($_POST['username']) && !empty($_POST['password']) &&(!empty($_POST['cpassword'])) && $_POST['password'] == $_POST['cpassword'] ) {
  33. $full_name=$_POST['full_name'];
  34. $email=$_POST['email'];
  35. $username=$_POST['username'];
  36. $password=$_POST['password'];
  37.  
  38.  
  39.  
  40. $query=mysql_query("SELECT * FROM users WHERE username='".$username."'");
  41. $numrows=mysql_num_rows($query);
  42.  
  43. if($numrows==0)
  44. {
  45. $sql="INSERT INTO users
  46. (full_name, email, username,password)
  47. VALUES('$full_name','$email', '$username', '$password')";
  48.  
  49. $result=mysql_query($sql);
  50.  
  51. if($result){
  52. $messages = "Account Successfully Created";
  53. } else {
  54. $messages = "Failed to insert data information!";
  55. }
  56.  
  57. } else {
  58. $messages = "That username already exists! Please try another one!";
  59. }
  60.  
  61. } else {
  62. $messages = "All fields are required!";
  63. }
  64.  
  65. function submitForm()
  66. {
  67. var data = $("#register-form").serialize();
  68. var formNm=$("#refister-form");
  69. var message=$(formNm).find(".msgs");
  70. var formTitle=$(formNm).find(".formTitle");
  71.  
  72. $.ajax({
  73.  
  74. type : 'POST',
  75. url : '../includes/register.php',
  76. data : data,
  77. beforeSend: function()
  78. {
  79. $("#btn-submit").html('<span></span> &nbsp; sending ...');
  80. },
  81. success : function(data)
  82. {
  83. message.html('');
  84. formTitle.css("display","none");
  85. setTimeout(function(){
  86. $('.formTitle').css("display","block");
  87. $('.msgs').html(data);
  88. $('input').not(':input[type=submit], :input[type=hidden]').val('');
  89. }
  90. ,3000);
  91. }
  92. });
  93. return false;
  94. }
Add Comment
Please, Sign In to add comment