i try to send data (PersonName) from vue axios request to php script but git this error in php file :
Warning: Undefined array key "Person" in C:\xampp\htdocs\linktree-vue\linktree-Create-Page.php on line 7
null
i tried follwoing :
const Pagedata = {
Person: "Youmna",
};
const options = {
method: 'POST',
url: 'http://localhost/linktree-vue/linktree-Create-Page.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: Pagedata
};
axios.request(options)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
php file (linktree-Create-Page.php) :
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: http://localhost:8080");
// Allow any domain to access the API
header("Access-Control-Allow-Origin: *");
$PersonName = $_POST['Person'];
print_r($PersonName);
echo json_encode($PersonName);
?>
Note : files pathes is correct, the request in f12 window is giving response 200 (success request) .. but doesnot read my data