Hi all,
I am using session variables while error checking a form. The form data is being passed to a page that checks to make sure certain fields are filled in. If they are not, the user is placed back on the form page with all the information they already put in still there. This works beautifully the first time the user forgets to fill in a field, but drops all of the session variables the second pass through. (if the user forgets again to fill in a field.) So when the form comes back there is no info displayed.
the form page:
<?
include("scontrol/include.inc");
if (empty($HTTP_GET_VARS["speaker_id"])) {
session_start();
}
if (!empty($HTTP_GET_VARS["speaker_id"])) {
$query = "select * from speaker_info where speaker_id=" . stripslashes($HTTP_GET_VARS['speaker_id']);
$result = mysql_query($query) or die(mysql_error());
$result_array = mysql_fetch_array($result, MYSQL_ASSOC);
}
if (isset($HTTP_SESSION_VARS)) {
$result_array = $HTTP_SESSION_VARS;
}
?>
The Error Checking Page:
<?
include("scontrol/include.inc");
session_start();
$sessionvars=$HTTP_SESSION_VARS;
session_destroy();
if (is_array($sessionvars)) {
foreach ($sessionvars as $session_name => $session_value) {
unset($$session_name);
}
}
unset($sessionvars);
session_start();
foreach ($HTTP_POST_VARS as $post_name => $post_value) {
session_register($post_name);
// echo "Key: $post_name; Value: $post_value<br>\n";
}
if (empty($HTTP_POST_VARS["firstname"])) {
$errors1[]="firstname";
}
if (empty($HTTP_POST_VARS["lastname"])) {
$errors2[]="lastname";
}
if (empty($HTTP_POST_VARS["email"])) {
$errors3[]="email";
}
if (empty($HTTP_POST_VARS["tnumber"])) {
$errors4[]="tnumber";
}
if (empty($HTTP_POST_VARS["organization"])) {
$errors5[]="organization";
}
if (!empty($errors1)) {
session_register("errors1");
Header("Location: feeform.php?");
} else if (!empty($errors2)) {
session_register("errors2");
Header("Location: feeform.php");
} else if (!empty($errors3)) {
session_register("errors3");
Header("Location: feeform.php");
} else if (!empty($errors4)) {
session_register("errors4");
Header("Location: feeform.php");
} else if (!empty($errors5)) {
session_register("errors5");
Header("Location: feeform.php");
} else {
$mailto = "christophermartin@starpower.net";
$body = "First Name: " . $HTTP_POST_VARS["firstname"] . "\n\nLast Name: " . $HTTP_POST_VARS["lastname"] . "\n\nOrganization: " . $HTTP_POST_VARS["organization"] . "\n\nPhone: " . $HTTP_POST_VARS["tnumber"] . "\n\nEmail: " . $HTTP_POST_VARS["email"] . "\n\nComments: " . $HTTP_POST_VARS["comments"] . "\n\n" . $HTTP_POST_VARS["formmail_subject"] . "\n\n";
mail ($mailto, "Speaker Information Query", $body, "From: web@totalaccess.com");
}
?>