Welcome Guest, Not a member yet? Register   Sign In
Active Record "insert" is not working properly
#7

[eluser]Daksh Mehta[/eluser]
yes, i am using Ajax to validate username if its available or not. that's it .
And i am beginner, so i can judge it.
Here is my js file:
Code:
user_validated = 0;
passwd_validated = 0;
function user_available(){
    $.ajax({
          type: "POST",
         url: "http://localhost:8888/ptcan/index.php/ajax/username_available/"+$("#username").val(),
          success: function(msg){
            if(msg == 1){
                $("#username_status").html("<font class=\"succ\">"+$("#username").val()+" is available!</font>");
                user_validated = 1;
                 reg_validate();
            }
            else {
                $("#username_status").html("<font class=\"err\">"+$("#username").val()+" is not available, try again!</font>");
                user_validated = 0;    
                 reg_validate();
            }
        }
     })
    
}
function pass_check(){
    if(($("#password").val() != $("#password2").val())){
                $("#password_error").html("<span class=\"err\">Password do not matches!</span>");
                passwd_validated = 0;
    }
    else {
        $("#password_error").html("<span class=\"succ\">Password matched!</span>");
        passwd_validated = 1;
    
    }
    reg_validate();
}
function reg_validate(){
    if((user_validated == 1) && (passwd_validated == 1))
        $("#regBtn").css("display", "block");
    else
        $("#regBtn").css("display", "none");
}


Here is my ajax controller:
Code:
&lt;?php
class Ajax extends CI_Controller {
    public function __construct(){
        parent::__construct();    
    }
    public function username_available($username = ""){
        if($username != ""){
            $q = $this->db->query("SELECT username FROM members WHERE username = ?", array($username));
            if($q->num_rows() == 0){
                echo "1";
            }
            else {
                echo "0";
            }
        }
        else {
            echo "<span class=\"err\">Username is required!</span>";    
        }
    }
}
?&gt;


Messages In This Thread
Active Record "insert" is not working properly - by El Forum - 07-31-2011, 09:13 AM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 08:55 PM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 08:58 PM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 09:37 PM
Active Record "insert" is not working properly - by El Forum - 08-02-2011, 12:20 PM
Active Record "insert" is not working properly - by El Forum - 08-02-2011, 05:12 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 01:07 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 01:36 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:29 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 04:04 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 05:49 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:26 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:41 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:46 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 01:14 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 02:16 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 03:00 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 03:26 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 11:15 AM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:38 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:45 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:58 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 09:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB