Forum Moderators: coopster

Message Too Old, No Replies

Sessions Nightmare

         

briesm

8:46 pm on May 27, 2005 (gmt 0)

10+ Year Member



Hey, I have a form which links to another php document so I need to pass along the form data that was entered when I load this other php document so the data is still entered as they continue. I checked my php info file and it did say "sessions support enabled" although autostart was disabled.
Anyway, I've also tried putting session_start in the beggining to no avail...here's the relevant code...
in the main php file i put a <?php
session_start();
?> in the beggining...
I attempt to pass along the data like so:
<?php
$field_territory = ""; //Territory Field, default as blank
if (isset($_SESSION['territory'])) $field_territory = $_SESSION['territory'];
?>
<td width="83%" valign="top"><b><input type=text value="<?php echo $field_territory;?>" name="territory" size="6">

This is also in the other php file that is called upon yet the data that is entered into that text field never carries on...any clue why?

StupidScript

9:12 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to also ensure that
territory
is actually being written to the session:

<?php

session_start();

$field_territory = "";

if (isset($_SESSION['territory'])) {

$field_territory = $_SESSION['territory'];

}

elseif ($_POST['territory']) { //Assuming form uses POST method

$_SESSION['territory'] = $_POST['territory'];

$field_territory = $_SESSION['territory'];

}

?>

<edit>Welcome to WebmasterWorld, briesm!</edit>

briesm

9:22 pm on May 27, 2005 (gmt 0)

10+ Year Member



You are the man....er the woman...you don't wanna know how much time I spent on this one haha