Click here to Skip to main content
15,035,283 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi all

i am not able to get control into the register-inserting.php from the below script.
pls guide me whats wrong in it?.

When i click on the button, the alert "All not empty is working".

<script type="text/javascript" >
    $(document).ready (function() {
    $("#btnSubmit").click(function(e) {
    var username = $("#username").val();
    var email = $("#email").val();
    var password = $("#password").val();
    var firstname = $("#firstname").val();
    var lastname = $("#lastname").val();
    var subscribe = $("#subscribe").val();
    var terms = $("#terms").val();
    var dataString = 'username='+ username + '&email=' + username + '&password=' + password + '&firstname=' + firstname + '&lastname=' + lastname + '&subscribe=' + subscribe + '&terms=' + terms;

    if(username=='' || email=='' || password=='' || firstname=='' || lastname=='' || subscribe=='' || terms=='')
    alert("all empty");

    alert("all not empty");
        url: "register-inserting.php",
        data: dataString,
        cache: false,
        type: "POST",
        success: function()
    return false;

Suvendu Shekhar Giri 6-Dec-15 9:06am
Try to read your question yourself. Isn't it very confusing?
"All not empty is working" means what?
Is it "all not empty" is working?
or "all not empty" is not working? or what else?
jim1972 6-Dec-15 9:13am
ys pls, its a typo.
"All not empty" working.

1 solution

Do you wan't to make ajax request when u're field is not empty?
If is this, check your data string,
it isn't the valid format for transmit data on jquery,
make data like this:

data:{key1 : value1, key2: value2}

take a look at:

you'll see data is a JSON object, and if it a string, make it at the same format (not GET param)

var dataString = "{var1 : "+ value1 + ", var2:"+value2+"}";

And normally u will show ur $(".message).fadein().show()

take a llok for this and answer me
jim1972 6-Dec-15 10:08am
i changed the dataString as below.
var dataString='{username:"jim1972",email:"",password:"aaa",firstname:"jim",lastname:"john",subscribe:"2",terms:"3"}'

even, the success message is displayed.
How can i check using some breakpoint in my inserting page?

this is my pho inserting page.

alert("reached at configure!");</script>';
$sql="Select Count(*) from users where username='" . $user . "'" ;
if ($query=== false){ exit("<pre>".print_r(sqlsrv_errors(), true));}

if ($query[0]==0) /*here, $query[0]) returns the number of rows*/
$datetime_variable = new DateTime();
$requestedDate = date_format($datetime_variable, 'Y-m-d H:i:s');

$sql="Insert Into Users(UserName,Email,Pwd,FirstName,LastName,Gender,RequestActivationOn,ReceiveNews,CreatedOn)
if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}

Member 10269884 7-Dec-15 0:21am
sorry, i don't understand what you want to do?!!
when i look a ur code, u want to insert ur form data in a sql database right?
but u want some "checkpoints" for connection/statement/validation?
when if do an AJAX call, u might be to return some data, right? (if an error, if config not load,etc ???)

then, when u call some server function and validate it with js, maybe u resend data from server to client?
something like
{'statut': 200, 'message': "success", 'dataToResend': {//all the data u want}}

but u can't do any JSON array in php.
So u might encode a php array representating ur data and encode it to js...

take a look at:

if i answer u right, the next step is to format ur data in ur html passing by javascript.

might i help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900