Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Is this possible with jquery, ajax and php

    What im wanting to do is use jquery and ajx for live validation, so lets say i wanted to change my current passowrd in my usercp.php and when i typed in my current password i would have on the side if it was corrent or not, so if it was corrent display "corrent" or if it was wrong do "wrong password", and id want php in the background grabbing his password from the database, and checking if it was corrent. Is this possible?

    Hopefully it is, anythings possible now'a days :P

    Thanks, KJD.

  • #2
    New Coder
    Join Date
    Jun 2009
    Location
    West Sussex
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Yes.

    use onkeyup

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Could you explain a bit more please?

    Thanks

    KJD.

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes this is possible, using ajax...
    and php/mysql connection.

    http://www.roscripts.com/Ajax_form_validation-152.html

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Thanks Kevin for the link, but i was looking for one when its live, so when you type it, it tells you then and there not when you click submit =p

    KJD.

  • #6
    New Coder
    Join Date
    Jun 2009
    Location
    West Sussex
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 4 Posts
    For instance (THIS IS NOT TESTED) you could have this:

    Code:
    <input type="text" id="username"><br>
    <span id="returnMessage"></span>
    Then at the botton of the page or in an external file have

    Code:
    $('#username')..keyup(function(event){
    
    var username = $('#username').val();
    
    $.post("check.php", { username: username" },
      function(data){
        $('#returnMessage').html(data);
      });
    
    });
    Then on check.php this will be my example.

    PHP Code:

    // NO SECURITY ON THIS CBS

    if ($_POST['username'] == 'Jack'){

    echo 
    'This username is taken';

    }else{

    echo 
    'This username is free';

    }

    ?> 

  • #7
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Thanks for your answers. Isnt there anyway i can check the database? like do an sql query and then echo weather its available or not? or is that not possible?

    Thanks, KJD.
    Last edited by Kev0121; 06-28-2009 at 01:00 PM. Reason: spelling errors

  • #8
    New Coder
    Join Date
    Jun 2009
    Location
    West Sussex
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Kev0121 View Post
    Thanks for your answers. Isnt there anyway i can check the database? like do an sql query and then echo weather its available or not? or is that not possible?

    Thanks, KJD.
    Well yeh. In the PHP FILE

    PHP Code:
    <?php

    // DB CONFIG UP HERE?
    // NO SECURITY ON THIS CBS

    $username mysql_real_escape_string($_POST['username']);

    $checkUser mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");

    if ((
    mysql_num_rows($checkUser)) == '0'){

    echo 
    'This name is free';

    }else{

    echo 
    'This name is taken';

    }

    ?>
    Sorry for awful coding ;D


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •