I have an index.html file
<section id = "AddFromDB">
<form action="./phpFile.php" method="POST">
<input type="text" id="inputUserID" placeholder="Lecturer ID" name="userID"></input>
<button type="submit" id="submitButton">Submit</button>
</form>
</section>
and a phpFile.php file
<?php
echo "Hello";
?>
and I am confused because when I run the php file even by itself (using its directory) in Firefox URL it doesn't show anything.
- I checked online and I am not using the short version tags for php.
- checked my php -v (It is installed, running latest php)
- Tried using the URL system directory as well as a live sever extension from Visual Code
I do know that it is accessing the php file as I had other code in there but it was showing me the actual lines of the php file and not the echos. Nevertheless, it is not working for something this basic and I have no idea why.
EDIT: They both are in the same folder
EDIT (2): "Page Source" results
for index.html
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>To-Do List</title>
<link rel="stylesheet" href="./reset.css" />
<link rel="stylesheet" href="./style.css" />
<script type="text/javascript" src="./javascript.js"></script>
</head>
<body>
<header>
<h1>
To-Do List
</h1>
</header>
<section id="saveTaskSection">
<div id="TAdiv">
<textarea id="toDoListTA" rows="8" cols="80"></textarea>
</div>
<button id="saveTaskButton" type="button" onclick="saveTask()">
Save Task
</button>
</section>
<section id = "AddFromDB">
<form action="./phpFile.php" method="POST">
<input type="text" id="inputUserID" placeholder="Lecturer ID" name="userID"></input>
<button type="submit" id="submitButton">Submit</button>
</form>
</section>
<section id="showTasksSection"></section>
</body>
for phpFile.php
<?php
echo "Hello";
?>
I have been notified that php requires a server in order to run. My apologize. Thank you for the information.
FOR ANY FUTURE READERS, THE COMMENTS BELOW ARE EXTREMELY HELPFUL. ALSO IF YOU ARE ON VISUAL STUDIO CODE OR ON ANY OTHER CODE EDITOR, CHECK THE EXTENSIONS/PLUGINS FOR YOUR CODE EDITOR AS THEY MIGHT HAVE ONE FOR PHP SERVER, FOR VISUAL CODE THERE IS ONE, IT MAKES ITS OWN localhost(port number) AND INTEGRATES SMOOTHLY WITH YOUR INDEX.HTML AND ANY CHANGES