In basic structure, here's a way to do it.
PHP Code:
<?php
// Decide whether we show the form, or try to process the form details
$showform = true;
// Set a flag for showing timesheet done message, and doing the redirect
$timesheet = false;
if (isset($_POST['submit'])) {
// Form has been submitted - try to process
// All your connection, form variables and SQL code goes here
// You should already have the necessary code from previous posts
// Assuming all went OK - allow the page to redirect
$timesheet = true;
$showform = false;
}
?>
<html>
<head>
Put whatever other header tags are needed here
<?php
if ($timesheet === true) {
// Set the redirect metatag
echo '<meta http-equiv="refresh" content="5;url=http://website/page.php">';
}
?>
</head>
<body>
<?php
if ($showform === true) {
?>
<form action="" method="post">
<!-- Put the form here -->
</form>
<?php
}
?>
<?php
if ($timesheet=== true) {
echo '<p>Your timesheet has been saved.</p>';
}?>
</body>
</html>
Bookmarks