Sessions not getting updated

From: Mountain Man (eightypoundpack_at_yahoo.com)
Date: 02/29/04


Date: 29 Feb 2004 00:33:03 -0800

Hi,

I posted on this matter earlier with the subject line "Trouble with
sessions," but someone else started a different thread with the same
subject line that arrived before my post, so I'm changing my subject
line in order to avoid confusion.

I was asked to provide a code example for analysis, so here it is,
along with a
a description of what the problem is.

I'm working with sessions and the values for HTML text fields
(input="text") aren't getting updated after the first time I submit
the form. If I shut down my browser and start anew, I can write to the
session just once, as before. On the other hand, radio buttons -- used
with the Sticky Multivalued Parameters script on pages 170-171 of
O'Reilly's "Programming PHP" -- are updated every time. Here's an
example of my code. Many thanks to anyone who can make sense of what's
going on here.

Best wishes,

Mountain Man

<html>
<head>
        <title>First Form Sessions</title>
</head>
<body>
        <form action="form_processor.php4" method="POST">
                First Name: <input type="text" name="firstName" value="<?php echo
$firstName ?>" /><br />
                <input type="submit" />
        </form>
        
</body>
</html>

// Next, the form processing script which is on another page.
// In my more complex script of actual use the form is only
// included if it doesn't pass validation.

<?php
        session_start();
        session_register("firstName");
?>

<html>
<head>
        <title>Form Processor Sessions</title>
</head>
<body>

<?php
echo "$firstName<br />";
include 'first_form.php4';
?>

</body>
</html>


Quantcast