I'm building a simple message sending service with HTML, PHP, and MySQL.
guestbook --- directory
ㄴ addMessage.php
ㄴ guestbook.php
...
index.php
at index.php, I included guestbook.php
to use functionality in that file.
<?php include("./guestbook/guestbook.php") ?>
at guestbook.php
, I made a simple form to allow writing messages for only logged user, and the data will be send to addMessage.php
as I wrote in the code.
<div style="position:absolute; top: 15%; left:25%; width:50%;">
<form action="addMessage.php" method="post">
<div class="form-group">
<label for="exampleFormControlTextarea1">Write some message!</label>
<?php
if (isset($_SESSION['id'])) {
echo '<textarea class="form-control" name="message" id="exampleFormControlTextarea1" rows="3" placeholder="~~~~"></textarea>';
echo '<button type="submit" class="btn btn-primary">write message</button>';
} else {
echo '<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="You should login first" readonly></textarea>';
echo '<button type="submit" class="btn btn-primary" disabled>write message</button>';
}
?>
</div>
</form>
</div>
and addMessage.php
, I put only one line of code to check whether it works.
<?php
// $conn = mysqli_connect("localhost", "alphatrox", "alphatrox", "cryptogame");
// for test
echo $_POST["message"];
?>
But when I send a message, I meet the error message that the addMessage.php
(the URL was http://localhost/addMessage.php
.) does not exist even I created it in the same directory.
Not Found
The requested URL was not found on this server.
Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/8.1.2 Server at localhost Port 80
Can you tell me what I'm doing wrong? I'm facing trouble...
thank you.