chimniii



Sometimes we don't give name to specific input box or name become mismatch in php and html this situation leads to the undefined index problem. Undefined index issue arrise when php unable to detect input box name or variable name defined in html or javascript. Here I am going to explain How this problem can resolve?

JS        

var name='cofee'                                                                                        
$.ajax({
method:'post','
url:'post_data.php',
data:{name:name},
dataType:'json',
success:function(data)
{
console.log(data)
},
error:function(data){
console.log(data)
}
})

php
<?
Header ('contentType:application/json');
error_reporting(1);

if(isset($_POST['name']))
{
echo $_POST['name']
},
else
{
echo 'something wrong occured';
}

?>
Hope this will solve your problem Happy coding..

chimniii.com