I have one PHP file. And I have multiple HTML files.
At first I show the first HTML file when the PHP file is loaded. So I included the code from "page1.html" into the PHP file.
Now after clicking the submit button and the validation on this PHP file I want to replace the current HTML file with another one.
But when I include page2.html after the validation was successful, it shows just the body content of the page2.html file under the "page1.html" content.
I want to replace the entire html file, not just a few elements. And it has to be in the PHP file where the first file was included too.
Is there any solution?
<?php
include 'page1.html';
// define variables and initialize with empty values
$Content "";
$Error = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (!isset($_POST["name"]))
{
$Error = "There is an error.";
}
else
{
$Content = $_POST["content"];
}
if (empty($Error))
{
include 'page2.html';
}
}
?>
Use condition in your PHP
file
<?php
if (isset($_POST))
{
include 'page2.html';
}
else
{
include 'page1.html';
}