0

Hello, I have a function to insert a new user into the database and it returns an empty data from the page I use to post it with."Undefined" actually... Here is the code:

//insert new user into database

 $("#insert_new_btn").live('click', function(){
     var user_username = $("#insert_new_user").val;
     $.ajax({
     type: "POST",   
     url:"insert_nw_usr_script.php",
     data:{insert_new_usr:user_username},
     success:function(insert_a_user)
     {$('#inserted_user').html(insert_a_user).show();}
     });
     });

This is the the php page, I haven't written the mysql script yet.I'm just printing the user on the screen, but I'm getting an empty response

<?php
$insert_new_usr = $_REQUEST['insert_new_usr'];
echo $insert_new_usr;

?>
2
Contributors
2
Replies
11
Views
4 Years
Discussion Span
Last Post by SMode55
0

This is the the php page, I haven't written the mysql script yet.I'm just printing the user on the screen, but I'm getting an empty response

Why you are using $_REQUEST?

Where you in your PHP code that has a insert_new_usr?

Undefined in javascript means that you didn't define the variable.

In PHP it goes like this:

mitch is undefine in my PHP code

To define it

I have to do this:

$mitch = $_POST['mitch'];

that will make sure that it is available for my query or code to function.

Without it ... it won't and most likely it will be undefine until I define it.

0

Damn it I missed one letter in the input field's id insert_new_user was insert_new_usr.

This question has already been answered. 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.