I want to have an HTML/PHP simple form on Apache. I would like the user to submit some data and then this data should be shown on the same page after submission. I want to have it all in a Docker container.
It might be the Docker issue, because it works on localhost.
I have PHP installed on my Ubuntu system. However, after submitting a form, I can't see the data I provided.
File index.html
<?php
$message = "";
if(isset($_POST['SubmitButton'])){ // Check if form was submitted
$input = $_POST['inputText']; // Get input text
$message = "Success! You entered: ".$input;
}
?>
<html>
<body>
<form action="" method="post">
<?php echo $message; ?>
<input type="text" name="inputText"/>
<input type="submit" name="SubmitButton"/>
</form>
</body>
</html>
Dockerfile
FROM webdevops/php:8.2
RUN apt update -y && apt upgrade -y
RUN apt install -y apache2
RUN apt install -y apache2-utils
RUN sudo a2enmod php8.2
WORKDIR /var/www/html
EXPOSE 80
COPY index.php /var/www/html/post
CMD ["apache2ctl", "-D", "FOREGROUND"]