travel_form.php
<?
<form action="form_actions.php" method="POST">
// ... travel_form code
<input type="submit" name="button" value="Submit">
<input type="submit" name="button" value="Save & Continue">
<input type="reset" name="clear_button" value="Clear">
<input type="submit" name="button" value="Preview">
<input type="submit" name="button" value="Logout">
//....
</form>
?>
form_actions.php
<?
session_start();
// This looks frighteningly familiar...:
switch($HTTP_POST_VARS["button"]) {
case "Submit":
// ...submit code
break;
case "Preview":
// preview code [preview on this page]
// use the back button to return
break;
case "Save & Continue":
// ...save and continue code
// & rightback to the filled "travel_form.php"
break;
case "Logout":
echo("<font size=4 color=red>You logged out! Thank you for using TLF. </font><BR>");
include("http://127.0.0.1/login.php");
session_unset($verified_user);
session_destroy();
break;
default:
// ...
}
?>
My questions are:
1. how can i make the session work with this code[means when i press back button or forward, i will get my old values in the form.]?
First, you need to make sure that you're NOT sending any expiration date in the header, nor a pragma no-cache directive.
I can't help you with the PHP sessions shtuff, I "rolled my own" session manager before PHP had built-in sessions, and I've used it ever since.
- When i will click on "Save & Continue", how can i get back to 'travel_form.php' with the filled values in it?
Whenever you need to do stuff like this, you have to assign those variables when you're generating the form. Typically, when I need to re-populate a form with data from the last post, I build the form dynamically, assigning the values from the last post. For example:
Name: <input type="text" name="name" value="<?php echo $HTTP_POST_VARS["name"]; ?>">
This will populate the form field with whatever values were sent in the POST directive.
While this is pretty simple for text-fields, it gets more complex for things like drop-down menus and radio buttons, for which I've designed a handful of custom functions.
Also, if you're sending your site visitor from one form to the next and then to the next, you might wanna consider either stashing the data from each post in a database somewhere, or carrying all the data from each post in hidden form elements. Hidden form elements should run a little faster, but it also gives us clever folks (who enjoy creating our own forms and submitting them to remote servers!) the opportunity to do bad things to the data.
- even session_destroy() in the logout coding won't work, something missing?
Sorry, no PHP sessions experience.
Reagrds,
Fat. [/B][/QUOTE]