Unable to access POST variables on the server-side
I am trying to access a variable value. Here is my code:
- <script language="javascript" type="text/javascript">
- function UpdateRecord(){
- $.ajax({
- type: "POST",
- url: "test.php",
- data: {name:"EG13291001"},
- success: function(response)
- {
- alert("Success");
- }
- });
- }
- </script>
- <input type='button' id='button_id' value='Update' onClick='UpdateRecord()'>
Here is my php code(test.php):
- <?php
- $num = (isset($_POST['name']) ? $_POST['name'] : "unable to access the number");
- echo $num;
- $link = mysql_connect('abcdef', 'hijklmn', 'opqrstuvwxyz');
- mysql_select_db('database', $link) or die(mysql_error());
- $db_query = "UPDATE main_table_copy SET `status`='Approve_Final03' WHERE number = '$num'";
- ?>
Here, I am unable to access name value. It is just displaying the message "unable to access the number".
What might be the problem?