Skip to content
PHP Logo

How can PHP be used to display a success message after saving data and then display a menu below it?

To display a success message after saving data and then display a menu below it in PHP, you can use a combination of conditional statements and HTML output. After saving the data successfully, you can set a flag or variable to indicate success. Then, you can check this flag and display the success message along with the menu using PHP echo statements.

php
<?php
// Assume data is saved successfully
$success = true;

if ($success) {
    echo "<p>Data saved successfully!</p>";
    echo "<ul>";
    echo "<li><a href='#'>Menu Item 1</a></li>";
    echo "<li><a href='#'>Menu Item 2</a></li>";
    echo "<li><a href='#'>Menu Item 3</a></li>";
    echo "</ul>";
}
?>