<html>
<head>
<title>Contact form</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>
<script type="text/javascript">
$(document).ready(function() {  
    var RecaptchaOptions = {
        theme : 'custom'
    };
    Recaptcha.create('your public key', 'recaptcha_image', RecaptchaOptions);
    Recaptcha.focus_response_field();
    $('#submit_button').click(function() { 
        $.ajax({
            type: 'POST',
            url: 'coustomer_rgistration.php',
            data: $('form#myform').serialize(),
            dataType: 'json',
            beforeSend: function() {
                var resp_field = $('#recaptcha_response_field').val();
                var name = $('#name').val();
                var email = $('#email').val();
                var pass = $('#pass').val();
                var add = $('#add').val();
                var zip_code = $('#zip_code').val();
                var l_number = $('#l_number').val();
                var m_number = $('#m_number').val();
                var city = $('#city').val();
                var state = $('#state').val();
                var country = $('#country').val();
                if (!resp_field[0] || !name[0] || !email[0] || !pass[0] || !zip_code[0] || !l_number[0] || !m_number[0] || !city[0] || !state[0] || !country[0]) { 
                    $('#output').html('All fields are required');
                    return false; 
                }
                emailpat = /^([a-z0-9])+([\.a-z0-9_-])*@([a-z0-9])+(\.[a-z0-9_-]+)+$/i;
                if (!emailpat.test(email)) {
                    $('#output').html('The e-mail address is not valid.'); 
                    return false;
                }
            },
            success: function(response) {
                if (response.status == 'success') {
                    $('#formcont').html();
                }
                $('#output').html(response.errmessage);
            }
        });

    });
}); 
</script>
</head>
<body>
    <h1>Contact form</h1>
    <div id="formcont">              
        <form id="myform">
            <p>
                <label for="naam">Name:</label>
                <input type="text" name="name" id="name" size="30" />
            </p>
            <p>
                <label for="email">E-mail:</label>
                <input type="text" name="email" id="email" size="30" />

            </p>
            <p>
                <label for="">Password:</label>
            <input type="password" name="pass" id="pass" size="30" />
            </p>
                <p>
                <label for="recaptcha_response_field">Address:</label>
        <input type="text" name="recaptcha_response_field" id="recaptcha_response_field" size="20" />
            </p>

                <p>
                <label for="">Zip code:</label>
            <input type="text" name="zip_code" id="zip_code" size="30" />
            </p>
                <p>
                <label for="">Land Line Number:</label>
            <input type="password" name="l_number" id="l_number" size="30" />
            </p>

                <p>
                <label for="">Mobile Number:</label>
            <input type="text" name="m_number" id="m_number" size="30" />
            </p>
                <p>
                <label for="">City:</label>
            <input type="text" name="city" id="city" size="30" />
            </p>
                <p>
                <label for="">State:</label>
            <input type="text" name="state" id="state" size="30" />
            </p>


                <p>
                <label for="">Country:</label>
            <input type="text" name="country" id="country" size="30" />
            </p>


            <div id="recaptcha_image"></div>
            <p>
                <!--<label for="recaptcha_response_field">address:</label>
                <input type="text" name="recaptcha_response_field" id="recaptcha_response_field" size="20" />-->
                <input type="button" value="Submit" id="submit_button" /> 
            </p>
        </form>
    </div>
    <div id="output"></div>
</body>
</html>

i m using light box form registration form i want to insert data in mysql database from light box but it is not work form shows in light box but data will not inserted into data base i m using another php code for inserting data in database what is the problem for this code pleas can any one help me....

Recommended Answers

All 5 Replies

What's the question?

Member Avatar for diafol

i m using light box form registration form i want to insert data in mysql database from light box but it is not work form shows in light box but data will not inserted into data base i m using another php code for inserting data in database what is the problem for this code pleas can any one help me....

Could you rephrase the issue and perhaps use some punctuation. I ran out of breath half way through the paragraph.

commented: i just want to insert data in database from light box +0

There are some steps that you can do to verify where the problem lies:

  1. Debug the JavaScript code with your browser to see if $("form#myForm").serialize() is returning what is expected.
  2. Use your browser network watcher to ensure that the data is being sent
  3. Debug your PHP code to ensure that the data is recieved

If the data is recieved in your PHP code then is just a matter of validating the data and inserting into the DB.

Good luck.

i just want to insert data in data base from light box i have another php file in which i put myinsert code it work s fine but i do some mistake in ajax and jquery i m not familir with ajax and jquery please give some idea how i can insert values in databse from light box

thanx to all of you to reply me my problem is solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.