I'm doing a chrome extension tutorial. The pop.html file has a POST form that connects to a php file called script.php. When I open script.php in the browser, the code executes an echo statement for testing purposes. However, when I run the chrome extension, I fill out the form and click the "submit" button, but instead of executing the code in script.php, it simply prints the code in script.php as plain text within the popup window.
Can anyone explain why the php code won't work for the extension? Throughout the day I've tried all the solutions described in the following posts: post1 post2 post3
Below are my files and code for reference.
In my MAMP directory, I have the following files in a project folder called "GlassExt":
manifest.json
{
"manifest_version": 2,
"name": "Glass - Connect to Database",
"description": "test database functionality",
"browser_action":{
"default_title":"Hello, Yo!",
"default_popup":"pop.html"
},
"version": "1",
"permissions": [
"http://localhost/*"
]
}
pop.html
(I previously had the "action" attribute set to "http://localhost/glassExt/script.php", but for some reason the form would not submit at all.)
<DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is a title, yo</title>
</head>
<body>
<form action="script.php" method="POST">
<input type="text" name="name" placeholder="Your Name"><br>
<input type="text" name="email" placeholder="Your Email"><br>
<input type="submit" value="Go">
</form>
</body>
</html>
script.php
<?php
$test = "this is a test";
echo $test
?>