Habsburg

oneMoreTime

May 22nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. -----HTML----
  2. <label>
  3. Korisničko ime
  4. </label>
  5. <br>
  6. <input type="text" name="korIme" id = "korIme" placeholder="ivoIvic69">
  7. <label id = "korImeE"></label>
  8. <br>
  9. <br>
  10.  
  11.  
  12. ---jQuery.js-----
  13. $(document).on("change","#korIme",function(){
  14. var txt = $("#korIme").val();
  15. if(txt != "")
  16. $.get("registracija.php", {source: "korIme", korIme: txt}, function(res) {
  17. res = JSON.parse(res);
  18. if(res == "FAIL")
  19. $("#korImeE").text("Korisničko ime je zauzeto");
  20. else
  21. $("#korImeE").empty();
  22. });
  23. else
  24. $("#korImeE").empty();
  25. });
  26.  
  27.  
  28. ----php-----
  29. $input = $_GET["source"];
  30. if($input == "korIme") {
  31. $korIme = $_GET["korIme"];
  32. $upit = "SELECT * from korisnici where korisnicko_ime = '".$korIme."'";
  33. $rez = $baza->selectDB($upit);
  34. $row = $rez->fetch_assoc();
  35.  
  36. $stanje = "";
  37. if($row == null) {
  38. $stanje = "OK";
  39. } else
  40. $stanje = "FAIL";
  41.  
  42. echo json_encode($stanje);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment