ChocolateLover
Programmer
I'm new to PHP.
I have a form that saves a record into a database.
If the required fields haven't been completed when the form is submitted, the form is redisplayed with a message and the fields that were already completed are retained using
to save the inputs and
to redisplay.
This works.
If the record has been saved successfully, I want to redisplay the form, ready to add a new record, but without the values from the previous record. What's the best way to do that?
I've tried setting
when I know that the record has been saved but when the form is submitted or the page refreshed $_SESSION['record_saved'] is no longer set.
I'd really appreciate any help.
I have a form that saves a record into a database.
If the required fields haven't been completed when the form is submitted, the form is redisplayed with a message and the fields that were already completed are retained using
Code:
session_start();
foreach($_POST as $key=>$value){
$_SESSION[$key]=$value;
}
Code:
<td><input type="text" name="author"
<?php
if (isset($_SESSION['author'])) {
echo ' value="' . $_SESSION['author'] . '"';
}
?>
></td>
This works.
If the record has been saved successfully, I want to redisplay the form, ready to add a new record, but without the values from the previous record. What's the best way to do that?
I've tried setting
Code:
$_SESSION['record_saved']=TRUE;
I'd really appreciate any help.