Session Variables Nightmare
I am having a nightmare with session variables (again!)
I have tried using the native Dreamweaver Session Variable options to set a form field as a session variable and then on the next page to display it, with no luck.
I have also tried the ecart set session value also which I sometimes get to work.
I have created a single element form like this (using the ecart behaviour);
<?php
if (!session_id()) session_start();
if(($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) {
$_SESSION["sessiontest"] = "".((isset($_POST["sessiontest"]))?$_POST["sessiontest"]:"") ."";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body><form action="thankyou_pdf.php" method="post">
<p>
<input name="sessiontest" type="text" />
</p>
<p>
<input type="submit" name="test" id="test" value="Test" />
</p>
</form>
</body>
</html>
And then try and display it here;
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo $_SESSION['sessiontest']; ?>
</body>
</html>
But I either get a blank page or a value that I had created in the form earlier in the day.
Can someone please tell me how to set a session variable from a form element using either a DW or Webassist behaviour and then show it on the next page?
Thanks in advance