Simple logic and sessions - Typo somewhere?
| From: | Damian Harouff | Date: | Wed, 15 May 2002 22:09:11 +0000 |
| Subject: | Simple logic and sessions - Typo somewhere? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97831@lists.php.net to get a copy of this message | ||
I am unable to get this to work. You start with
system_logic.php?system=a900. It's supposed to start with memory
selection, the proceed to hard drive, and onward. Instead, it starts
with videocard, and keeps going through the videocard set, instead of
at least progressing into hard drive.
This is with php 4.2.1 on Debian Linux.
Here are the 2 files:
system_logic.php
---------------------------------------------------------------------------------------
<?
session_start();
//if ($_GET[system] == "" && $_SESSION[system] == "") die ("No
system data.");
if ($_GET[system] != "") $_SESSION[system] = $_GET[system];
if ($_SESSION[memory] == "ret") {
$_SESSION[memory] = "CO";
$_SESSION[system] = $_GET[system];
} elseif ($_SESSION[memory] != "CO") {
$_SESSION[system] = $_GET[system];
$_SESSION[action] = "memory";
$_SESSION[location] = "Memory Selection";
Header("Location: systembuild.php");
}
if ($_SESSION[harddrive] == "ret") {
$_SESSION[system] = $_GET[system];
$_SESSION[harddrive] = "CO";
} elseif ($_SESSION[harddrive] != "CO") {
$_SESSION[system] = $_GET[system];
$_SESSION[action] = "harddrive";
$_SESSION[location] = "Hard Drive Selection";
Header("Location: systembuild.php");
}
if ($_SESSION[videocard] == "ret") {
$_SESSION[videocard] = "CO";
$_SESSION[system] = $_GET[system];
} elseif ($_SESSION[videocard] != "CO") {
$_SESSION[system] = $_GET[system];
$_SESSION[action] = "videocard";
$_SESSION[location] = "Video Card Selection";
Header("Location: systembuild.php");
}
print "end of minidemo";
?>
----------------------------------------------------------------------------------
systembuild.php
----------------------------------------------------------------------------------
<?
include("config.php");
session_start();
$retname = $_SESSION[action];
$_SESSION[$retname] = "ret";
print_r($_SESSION);
$link = mysql_connect($dbhost, $dbuser, $dbpass) or die ("no connection, man");
mysql_select_db($dbdb) or die ("no database, man");
$query = "SELECT * FROM config_" . $_SESSION[action] . " WHERE forsystem =
\"" . $_SESSION[system] . "\"";
$result = mysql_query($query) or die("no query, man");
print "<font face=\"arial\"><center>";
$outer = new ftable;
$outer->bodybgcolor = '058BAA';
$outer->caption = '<a href="http://www.unicortex.com/">'.
'<font color=orange size=4><B><big>Uni</font><font color=blue
size=5>Cortex</big></B></font></a> - <font color=green
size=4><B>' . $_SESSION[location] ;
$outer->radius = 20;
$outer->lineheight=3;
$outer->linecolor='CCCCCC';
$outer->width='75%';
$outer->printtop();
echo '<table cellpadding=0 cellspacing=0><colgroup><col
width="50%"><col><col width="50%"></colgroup><tr
valign=top><td>';
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row++;
blanker( "100", 4 );
$tempdesc = explode("|", $line[desc]);
$tempdesc = implode("<BR>", $tempdesc);
$pop = new ftable;
$pop->bodybgcolor = 'FFFFFF';
$pop->linecolor = 'AFAFAF';
$pop->captionbgcolor = 'FFFFFF';
$pop->caption = "<B>". $line[name] ." ::</B> <a
href=\"system_logic.php?system=$_SESSION[system]&additem=$line[name]\"><img
src=\"images/med_select.gif\"></A>";
$pop->radius = 8;
$pop->lineheight = 3;
$pop->width = '325';
$pop->printtop();
print "<B>For system:</B> " . formatSmall($line[forsystem], 0) .
"<BR>";
print "<B>Price:</B> " . formatSmall("$".$line[price], 0) .
"<BR>";
$pop->linecolor = '0CC303';
$pop->changebodybgcolor('AAFFAA');
print "<font size=\"1\"><a
href=\"nonexistantpopup.php\">View Information</a><BR>";
if ($line[picture] != "nopicture") print "<a
href=\"picturepopup.php\">See Picture</a>";
else print "<BR>";
$pop->printbottom();
if ($row != 3) echo
'</td><td>'.ft_blank(4,4).'</td><td>';
elseif ($row >= 3) echo '</td></tr><tr><td>';
}
echo '</td></tr></table>';
$outer->printbottom();
print '</center>';
mysql_free_result($result);
mysql_close($link);