I'm confuzzled. I thought I had a relatively good grasp on the usage of sessions, but apparently I was wrong. I was just making a script to play around with, and it seems that the session is initializing (lynx asks for cookie) but the variable I'm trying to register does not seem to actually be registering.
The main thing I'm playing with is running a step by step registration process entirely on one script. Right now, it just asks for name and address and then prints them out on the third page, or at least it would if I knew what I was doing wrong 🙂
Any ideas? I'll paste the script below:
<?
/*************************
FIRST STEP
**************************/
if (!isset($step))
{
session_start();
$pagetitle = "Sign up - step 1";
include ("auth/header.inc");
echo "<center>\n";
echo "<b><i>Step 1 not completed. Please fill out the form.</b></i><br>\n";
echo "<form method=\"post\" action=\"newuser1.php\">\n";
echo "<table border=\"0\">\n";
echo "<tr>\n";
echo "<td align=\"right\"><font color=\"white\"><b>Name</b></font></td>\n";
echo "<td align=\"left\"><input type=\"text\" name=\"name\" maxlength=\"20\" size=\"20\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Next\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<input type=\"hidden\" name=\"step\" value=\"1\">";
echo "</form>\n";
echo "</center>\n";
include ("auth/footer.inc");
}
/*************************
SECOND STEP
**************************/
else if ($step == 1)
{
session_start();
$pagetitle = "Sign up - step 2";
include ("auth/header.inc");
session_register("$name");
echo $name;
echo "<center>\n";
echo "<b><i>Step 1 completed. Please fill out the form for step 2.</b></i><br>\n";
echo "<form method=\"post\" action=\"newuser1.php\">\n";
echo "<table border=\"0\">\n";
echo "<tr>\n";
echo "<td align=\"right\"><font color=\"white\"><b>Address</b></font></td>\n";
echo "<td align=\"left\"><input type=\"text\" name=\"address\" maxlength=\"20\" size=\"20\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Next\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<input type=\"hidden\" name=\"step\" value=\"2\">";
echo "</form>\n";
echo "</center>\n";
include ("auth/footer.inc");
}
/*************************
THIRD STEP
**************************/
else if ($step == 2 )
{
session_start();
$pagetitle = "Registration complete!";
include ("auth/header.inc");
echo $name;
session_destroy;
}
?>