How do I destroy my sessions?  
Author Message
ledtool





PostPosted: 2004-2-22 18:46:18 Top

php-general, How do I destroy my sessions? I have 2 .php pages, one called emailForm.php and the other calle
email.php.

emailForm.php has the actual form to fill out to send an email to th
owner. If not all fields are filled out when you hit the Send button
the Send button calls email.php, checks to see what fields haven't bee
filled out, and sends the error messages back to emailForm.php, fill
in the fields that were filled in prior to hitting the send button
with the error message in red above the fields that weren't filled in.

Code excerpt from emailForm.php:

<?php
session_start();

require "header.php";

function fieldError($fieldName, $errors)
{
if (isset($errors[$fieldName]))
echo "<fon
color=RED>$errors[$fieldName]</font><br>";
}

?>

Further down:

<form action="/*email.php*" method="post">
<td nowrap align=right><font color="black" face="verdana
size="-1">First Name: </td>
<td colspan=2 align=left><? echo fieldError("Fname",$errors); ?>
<input type="text" name="Fname" value="<? ech
$formVars["Fname"]; ?>" size=40>
</td>


Code exerpt from email.php:

<?php

include "db.php";

session_start();

if (!session_is_registered("errors"))
session_register("errors");

$errors = array();

if (!session_is_registered("formVars"))
session_register("formVars");

foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname] = $value;

if (empty($formVars["Fname"]))
$errors["Fname"] = "The first name field cannot b
blank.";

if (empty($formVars["Lname"]))
$errors["Lname"] = "The last name field cannot b
blank.";

if (empty($formVars["userEmail"]))
$errors["userEmail"] = "The Email field cannot b
blank.";

if (empty($formVars["subject"]))
$errors["subject"] = "The subject field cannot b
blank.";

if (empty($formVars["zip"]))
$errors["zip"] = "The zip code field cannot b
blank.";

if (empty($formVars["body"]))
$errors["body"] = "Please type in a message.";

if (count($errors))
{
header("Location: *emailForm.php*");
exit;
}

session_destroy();


So my question is how do I destroy the session on both pages once th
email is sent successfully? If anyone needs more code to see, I ca
provide it. Thanks
 
Alex





PostPosted: 2004-2-22 18:46:00 Top

php-general >> How do I destroy my sessions? Try session unset via
-unset()-


For more info. check out
http://tinyurl.com/2twl