I am trying to access the token from my html page having input element having the token when i run this page on server (wamp) in windows 7. I am getting an error as undefined index on the "api_key" . How do i fix it ? php code:
<?php
$Cname=$_POST['api_key'];
if($Cname=="To-do")
{
$api_key=$_POST['api_key'];
$file1="i have some url here not mentioning it for valid reason".$api_key;
$data = file_get_contents($file1);
$json_o=json_decode($data);
echo "<pre>";
print_r($json_o);
echo "</pre>";
}
?>
//html page:
//script is within head
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "></script>
<script type="text/javascript">
$(document).ready(function() {
$("#postJson").click(function(event){
$.post(
"get_task_by_column.php",{hidden:$('#api_key').val()},
function(data) {
$('#response').html(data);
}
);
});
});
</script>
//body starts
<div>
<form>
<input type="hidden" name="api_key" value="024b427a5d41a62edd218bddb55ed1fc" id="api_key" >
<input type="text" id="txthtml">
<input type="button" value="Get tasks by column name" id="postJson"/>
</div>
<div id='response'></div>
</form>