Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <script>
  2.  
  3. $("#kys_SignUp_form").submit(function(event){
  4. event.preventDefault();
  5.  
  6. var $form = $(this);
  7. var $url = $form.attr('action');
  8. var $email = $("#email").val();
  9. var $username = $("#username").val();
  10. var $password = $("#password").val();
  11.  
  12.  
  13. $.ajax({
  14. type: 'POST',
  15. url: $url,
  16. data: { email: $email, password: $password, username: $username },
  17.  
  18. success: function(data) {
  19. alert("Transaction Completed!");
  20.  
  21. }
  22.  
  23. });
  24.  
  25. });
  26.  
  27. </script>
  28.  
  29. <form role="form" action="kys_SignUp.php" method="post" id="kys_SignUp_form">
  30. <div class="form-group">
  31. <label for="email" >Email address:</label>
  32. <input type="email" style="width: 300px" class="form-control" name="email" id="email" required>
  33. </div>
  34.  
  35. <div class="form-group">
  36. <label for="Username" >Username:</label>
  37. <input type="text" style="width: 300px" class="form-control" name="username" id="Username" required>
  38. </div>
  39.  
  40. <div class="form-group">
  41. <label for="password" >Password:</label>
  42. <input type="password" style="width: 300px" class="form-control" id="password" name="password" required>
  43. </div>
  44.  
  45. <button type="submit" class="btn btn-default">Submit</button>
  46.  
  47. </form>
  48.  
  49. <?php
  50.  
  51. include "kys_DbConnect.php";
  52.  
  53. $email = $username = $password = "";
  54.  
  55. if($_SERVER["REQUEST_METHOD"] == "POST"){
  56.  
  57. $email = cleanData($_POST["email"]);
  58. $username = cleanData($_POST["username"]);
  59. $password = cleanData($_POST["password"]);
  60.  
  61.  
  62. }
  63.  
  64.  
  65.  
  66. $stmt = $con->prepare("SELECT * FROM kys_users WHERE username=? OR email=?");
  67. $stmt->bind_param("ss",$username,$email);
  68. $stmt->execute();
  69. $stmt->bind_result($kys_id,$kys_email,$kys_username,$kys_password);
  70. $stmt->fetch();
  71.  
  72. if(isset($kys_username)){
  73.  
  74.  
  75.  
  76. echo "Username or Email already exists";
  77.  
  78. }
  79. else{
  80.  
  81. $insert = $con->prepare("INSERT INTO kys_users (username, email, password) VALUES (?, ?, ?)");
  82. $insert->bind_param("sss",$username,$email,$password);
  83. $insert->execute();
  84. header("Location: http://localhost/KeyStroke/index.html");
  85. exit();
  86.  
  87. }
  88.  
  89.  
  90.  
  91. function cleanData($data){
  92.  
  93. $data = stripslashes($data);
  94. $data = htmlspecialchars($data);
  95. return $data;
  96.  
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement