Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----HTML----
- <label>
- Korisničko ime
- </label>
- <br>
- <input type="text" name="korIme" id = "korIme" placeholder="ivoIvic69">
- <label id = "korImeE"></label>
- <br>
- <br>
- ---jQuery.js-----
- $(document).on("change","#korIme",function(){
- var txt = $("#korIme").val();
- if(txt != "")
- $.get("registracija.php", {source: "korIme", korIme: txt}, function(res) {
- res = JSON.parse(res);
- if(res == "FAIL")
- $("#korImeE").text("Korisničko ime je zauzeto");
- else
- $("#korImeE").empty();
- });
- else
- $("#korImeE").empty();
- });
- ----php-----
- $input = $_GET["source"];
- if($input == "korIme") {
- $korIme = $_GET["korIme"];
- $upit = "SELECT * from korisnici where korisnicko_ime = '".$korIme."'";
- $rez = $baza->selectDB($upit);
- $row = $rez->fetch_assoc();
- $stanje = "";
- if($row == null) {
- $stanje = "OK";
- } else
- $stanje = "FAIL";
- echo json_encode($stanje);
- }
Advertisement
Add Comment
Please, Sign In to add comment