Reputation: 19
i want to test my skills with php on 'localhost' with the php embedded in the 'page' ie
<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8" />
<title>test stuff</title>
<style> </style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<button id="b2" onclick="do_post()">post</button>
<script>
console.log("it begins");
// --- send a message to myself ---
function do_post()
{
console.log("at do_post()");
var arr = {"client": "fredi", "action": "mod", "rix": 6, "row": "yarn|white|5.59@"};
$.ajax({
type: "POST",
url: 'aaaaa.php',
data: arr,
//success: success,
//dataType: dataType
})
}
</script>
</body>
</html>
<?php
var_dump($_SERVER["REQUEST_METHOD"]);
if ($_SERVER['REQUEST_METHOD'] == 'GET')
{
echo ("caught GET");
var_dump($_GET);
}
else
{
echo ("caught POST");
var_dump($_POST);
}
?>
I know that the php is getting executed because i catch the 'GET' request to load the page because i see ... string(3) "GET" caught GETarray(0) { }
i looked at the .ini files but all i saw was "IF YOU DONT KNOW WHAT YOU'RE DOING STAY OUT"
I suspect that it is my 'localhost' server preventing me from harming my machine but i don't know that for sure.
Help please i am 84.7 yrs old and have been programming since 1960 but have had brain injury and am trying to keep it active.
Upvotes: 0
Views: 52
Reputation: 1
I like to keep a small footprint and so append the php to the html page, after the tag. I am writing a small store inventory monitor and the inventory is a dot-txt file. When i CRUD an item i want to tell the server what and where so that the 'database' is current. The PHP i have appended sees the initial GET sent by the browser to load the page. When I $.POST() or $.GET() to the same URL as the running page i dont see it. I am wondering if it is a 'localhost' issue or piss-poor programming on my part. wie when the browser sends a 'GET' i see it, when my code sends a 'GET' i dont.
Upvotes: 0