hi coders..

i need live availability code

i am using codeigniter. i am inserting values(username,password,email,phone number) by using array .

if the email is already in databse i need to show error message..

with out reloading the page....

thanks in advance.

4 Years
Discussion Span
Last Post by meda shiva

You will need to use JavaScript and ajax.
First you should create a php page that will return true or false for the values you are testing.

e.g. yourwebsite.com/ajax/checkemail.php?email=someone@somewhere.com

When you have done this your main page will use JavaScript to call the ajax page with the user input and update the main page depending on the result.


thanks paulkd..!

can u please suggest me how to use ajax in my javascript.

the below code for validation let me know how to cal ajax hear...

if(Pemail == "" || !Pemail.match(emailReg)){
            $("#ePemail").html("Please enter email");


Although I've not tested this..
Your ajax php page should query the database for the supplied email address and return json_encode(true) if the email address is already used and return json_encode(false) if not.

Your form will use the following (untested) jQuery:-


    //default form not submitted

    //prevent enter key in input field from submitting form
        if($("#submit-button").data("submitted")===false) {

    //trigger form submission


function checkEmail()
        type : "GET",
        url: '/path/to/your/ajax/checkemail.php',
        dataType: "json",
        data: ({
            email: $("#email").val()
        success: function(emailExists)
            if(emailExists) {
                alert("email already exists");
            } else {

My example shows three css ids: your-form for the <form id= tag, submit-button for the <input type="submit... tag and email for your user's email input field. You will need to substitute your own.

First thing to do is create and test your ajax page without using JavaScript - simply call the page as previously mentioned and output the word true or false.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.