It would seem that the information entered in the original form is not being sent to the preview page because all the fields are blank when they should repeat what was initially entered. Here is the code:
Code: Select all
index.php:
$fb = new Feedback;
if (isset($_POST['action'])) {
$fb->name = $_POST['name'];
if ($fb->valid()) {
$_SESSION['feedback'] = $fb;
return header('Location: ?action=preview');
}
}elseif ($_SESSION['feedback']) { // Coming back from preview
$fb = $_SESSION['feedback'];
}
$this->feedback = $fb;
$this->render('views/show_form.php');
}
show_form.php:
<? $feedback = $this->feedback; ?>
<form method="post" action="index.php">
<label for="name" ><strong>Your Name:</strong></label>
<input type="text" class="text" name="name" id="name" size="30" value="<?= $feedback->name ?>" /><br/>
<input type="hidden" name="action" value="form" />
<input type="submit" value="Preview" />
</form>
preview.php:
<? $feedback = $this->feedback; ?>
<ul>
<li>Name: <?= $feedback->name ?></li>
</ul>
<form action="" method="post">
<input type="submit" class="submit" value="Send Feedback Now" />
<input type="hidden" name="action" value="send"/>
</form>
Please help me with this...I don't get why it isn't storing what's in the form...it was working before and I don't know what happened.