"There are two problems there.  First, your session data is not getting
cleared.  Second, it is not getting reset with the new values.

For the former, in guestbook_save.php you can simply do a session_unset
(if you really want to clear all of them).  However this does not
handle an abnormals equence -- for example someone hits Back in the
middle of the process.

I don't understand why they are not getting set properly the second
time around.  It could be a condition in your code.  I'd have to see
the code to have an idea.

Try stripping the code WAY down so you have a test_add.php with a 1-
field form, and a test_review.php that displays that data and saves it
in a session variable, and test_save.php that just displays what it
receives in the session variables.  If that still fails, post the code.
If not, your problem lies in the difference between that and the
original code.
"

ok heres the code in the message body: hope it fits....
note: im in the middle of porting it from new code to old code so some
$_SESSION vars might show themselves time to time...
[guestbook_add.php: form to fill out:linked from admin.php(not shown)]
<?
session_start();
if(!empty($_SESSION['username'])){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/transitional.dtd";>
<html>
<head>
<title>Add GuestBook Entry</title>
<LINK rel="stylesheet" href="style/rnjresort.php" type="text/css">
</head>

<body>
<h1>Add guestbook entry</h1>
<div>
<table>
<tr>
<td>
NOTE: when filling out this form, make sure you fill the date out in the
format yyyymmddhhmmss. example: 20040401000000 would be april 1 2004 12
midnight. To insert the current date leave the date blank.
</td>
</tr>
</table>
</div>
<div>
<form method="post" action="guestbook_review2.php">
<table summary="Below is the entire form for adding your entry to the
guestbook">
<tr>
<td>
<label for="id-date">Date: </label><input type="text" name="date"
accesskey="a">  <label for="id-name">Name:</label> <input type="text"
name="name" accesskey="n" id="id-name">
</td>
<td>
<label for="id-email">Your Email address:</label> <input type="text"
name="email" accesskey="e" id="id-email">
</td>
</tr>
<tr>
<td>
<label for="id-website"> Your URL:</label> <input type="text" name="website"
accesskey="w" id="id-website">
</td>
<td>
<label for="id-referred"> How did you hear about us?</label> <input
type="text" name="referred" accesskey="d" id="id-referred">
</td>
</tr>
<tr>
<td>
<label for="id-comments"> Comments:</label> <textarea name="comments"
rows="5" cols="40" accesskey="c" id="id-comments"></textarea>
<center>
<input class="button" type="submit" value="submit" accesskey="s">  <input
class="button" type="reset" value="start over" accesskey="o">
</center>
</td>
</tr>
</table>
</form>
</div>


<img
src="http://www.w3.org/Icons/valid-html401";
alt="Valid HTML 4.01!" height="31" width="88">

</body>
</html>
<?} else {
header("location: login.html");}?>
[end of guestbook_add.php]
then the form gets submitted to the next one:
[guestbook_review2: give users the choice to back out before its too late
and type in again]
<?php
session_start();
$_SESSION['date']=$date;
$HTTP_SESSION_VARS['name']=$name;
$HTTP_SESSION_VARS['email']=$email;
$HTTP_SESSION_VARS['website']=$website;
$HTTP_SESSION_VARS['referred']=$referred;
$HTTP_SESSION_VARS['comments']=$comments;
if(!empty($_SESSION['username'])){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/transitional.dtd";>
<html>
<head>
<title>Confirm your post</title>
<LINK rel="stylesheet" href="style/rnjresort.php" type="text/css">
</head>

<body>
<h1>Confirm your post</h1>
<div>
<table summary="Instructions for Confirming your post">
<tr>
<td>
<p>Review your information below. If you need to return to the form to
change anything just click the start over button. If you are satisfied with
your listing click the continue button.</p>
</td>
</tr>
</table>
</div>

<div>

<table summary="Your posting information is below">
<tr>
<td>
Name:
<?php echo "$HTTP_SESSION_VARS[name]";?>
</td>
</tr>
<?php
if(!empty($HTTP_SESSION_VARS['email'])){?>
<tr>
<td>
<?php echo "<a href=\"mailto:$HTTP_SESSION_VARS[email]\";>My Email
address</a> ($HTTP_SESSION_VARS[email])";?>
</td>
</tr>
<?php }else{echo "";}
if(!empty($HTTP_SESSION_VARS['website'])) {?>
<tr>
<td>
<?php echo "<a href=\"http://$HTTP_SESSION_VARS[website]\";>My web site</a>
($HTTP_SESSION_VARS[website])";?>
</td>
</tr>
<?php } else {echo "";}
if(!empty($HTTP_SESSION_VARS['referred'])){?>
<tr>
<td>
Where did you hear about us?<br>
<?php echo "$HTTP_SESSION_VARS[referred]";?>
</td>
</tr>
<?php } else { echo "";}?>
<tr>
<td>
Comments:<br>
<?php echo "$HTTP_SESSION_VARS[comments]";?>
</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>
<input class="button" type="button" value="continue>>" accesskey="c"
onclick="window.location='guestbook_save.php';"
onkeypress="window.location='guestbook_save.php';">
</td>
<td>
<input class="button" type="button" value="start over" accesskey="s"
onclick="window.location='admin.php';"
onkeypress="window.location='admin.php';">
</td>
</tr>
</table>
</div>


<img
src="http://www.w3.org/Icons/valid-html401";
alt="Valid HTML 4.01!" height="31" width="88">

</body>
</html>
<?}else{
header("location: login.html");}?>
[end of guestbook_review2.php]
if they hit the continue button it takes them to guestbook_save.php, saves
to db and returns to admin.php...
[guestbook_save.php: saves and returns to admin page]
<?php
session_start();
if(!empty($_SESSION['username'])){
//check if name and comments are empty
//if so then return an error
//otherwise save
if($_SESSION['date']=="")
$_SESSION['date']=NULL;

if(!empty($HTTP_SESSION_VARS['name']) &&
!empty($HTTP_SESSION_VARS['comments'])){
include("libs/conf.db");
mysql_connect($host, $mysqluser, $mysqlpwd);
mysql_query("insert into rnjresort.guestbook values(NULL, '$_SESSION[date]',
'$HTTP_SESSION_VARS[name]', '$HTTP_SESSION_VARS[email]',
'$HTTP_SESSION_VARS[website]', '$HTTP_SESSION_VARS[referred]',
'$HTTP_SESSION_VARS[comments]')")||die(mysql_error());
//include("mail.php");
header("location: admin.php");
} else { ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/transitional.dtd";>
<html>
<head>
<title>error!</title>
<LINK rel="stylesheet" href="style/rnjresort.php" type="text/css">
</head>


<body>
<h1>ERROR</h1>


<div>
<table>
<tr>
<td>
<p>Error: At least name and comments are required to post here.</p>
</td>
</tr>
</table>
</div>

<div>
<input class="button" type="button" value="OK" accesskey="o"
onclick="window.location='form.html';"
onkeypress="window.location='form.html';">
</div>
</body>
</html>
<?php }}
else {
header("location: login.html");}?>

[end of guestbook_save.php]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to