I am working with a multipage form in which I want to carry along some variables in a session and use them to concatenate values to create some logic. The problem is, when I call them, I receive a "Notice: Undefined index: city" where city is the name of the variable I am calling.
The reason the post says (Sort of) is that the previous page actually uses this session variable to redirect!
Things I have done -
1. session_start (); on every page using these variables.
2. Validated my form (Also verified items are being past as post variables)
3.Tons of syntax changes
4. Google - a couple people had this problem, but it was either miraculously fixed, or no solution was provided at all...
Page 1: stores the city in a session variable.
<?php
//Invoke session to hold variables
session_start();
//Stores city value in a session variable from form so that it may be concatenated to text selections later on
$_SESSION['city'] = $_POST['city'];
//take value of city selected and redirect so that user may make selections within the selected city
switch($_SESSION['city'])
{
case 'Atlanta': header("Location: http://www.example.com/membertext/atlanta.php");
break;
case 'Birmingham': header("Location: http://www.example.com/membertext/birmingham.html");
break;
default: echo "Sorry, you must select a city";
}
?>
I use the $SESSION['city'] variable to determine the redirect, and that works fine. Howeverm once I arrive at the redirect, I try to call $SESSION['city'] again, and it fails...
Page 2
<?php 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 if(isset($_SESSION['city'])) {echo $_SESSION['city'];} else {echo "Sorry";} ?>......
truncated the rest of this....
Has this happened to anyone else..?