weikelbob
asked on
losing session variables
Please take a look at this script and see why I'm losing my sessions:
www.owndesigns.com/deed-david/admin/menuorder.txt
www.owndesigns.com/deed-david/admin/menuorder.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's working!
so far....
so far....
lol, Good, glad I could help.
Bobby
Bobby
ASKER
I didn't use your script, but I went back to my script and added an "a" in the sessions because you suggested to make them not only just numbers. Everything started working.
Thanks a lot.
Bob
Thanks a lot.
Bob
Ok I am glad it worked out. Thanks for the points.
<?php
session_cache_limiter('noc
session_cache_expire (40);
session_start();
error_reporting(E_ALL);
$errors=array();
if (isset($_POST['order2'])) {
unset($_POST['submit']);
foreach($_POST as $key => $value) {
if(!is_numeric($value)) {
$errors[]="Your changes are not numeric";
}
}
if(count($_POST) != count(array_unique($_POST)
//there are some duplicates. Use a foreach to detect them.
$errors[]="Your changes are invalid";
}
if (count($errors)==0) {
// Array elements are NOT unique OR not integer - you can use $a_unique_ints to see all the unique ints available.
if(isset($_POST['order2'])
for($j=1;$j<count($_POST) + 1;$j++) {
/* $a="order" . $j;
echo "a:" . $_POST[$a];
echo "<br><br>";
$query4="update deedtable set order1= '" . mysql_real_escape_string($
$result4= mysql_query($query4); */
}
}
}
}
echo <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Admin Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<div id="header">
<img src="images/header1.jpg">
</div>
<div id="whitearea">
END;
print_r($_SESSION);
if (count($errors)>0) {
$error = implode("<br />", $errors);
$error = "<span style=\"color:red;font-wei
echo $error;
}
echo "
<p style='text-align:center'>
To return to the admin home, click <a href='index.php'>here</a>.
</p>
<ul style='list-style-type:non
<table cellpadding='1' cellspacing='1'>
<form action='{$_SERVER['PHP_SEL
";
$i=0;
foreach (array(
array("menu" => "Testqqq", "order1" => 1),
array("menu" => "Testqqfdg", "order1" => 3),
array("menu" => "dfgdg", "order1" => 5),
array("menu" => "Tdfestdfg", "order1" => 6)
) as $row3) {
echo "<tr>";
echo "<td>";
$i++;
echo <<<END
<li>{$row3['menu']}
</td>
<td>
<input type="text" size="5" name="order<?php echo $i; ?>" value="{$row3['order1']}">
END;
$_SESSION['DD' . $i] = $row3['order1'];
$_SESSION['Thz'] = "TESTING123";
echo $_SESSION['DD' . $i];
echo "
</li>
</td>
</tr>";
}
echo <<<END
<input type="submit" name="submit" value="Update a page's order">
</form>
</table>
</ul>
<p style="text-align:center">
click <a href="admin-new.php">here<
</p>
</div>
<div id="clear1"></div>
</div>
</body>
</html>
END;
print_r($_SESSION);
?>