Folks - below is some crappy code I wrote to test something out. It picks up a username & password then posts that to a form and sets a session_ variable with the username. that works fine. I then want to post some more data on the second form and confirm that on a third page. It loses the session_username on the third one with some unintelligible (by me) message from the browser about the session already started. what?
For you helpful people's info I've got globals 'on' and the SID stuff on. I know I should be using $_SESSION[] and all that but I want to get a crude version going before going all flash like that.
Anybody got any clues? I've seen lots of posts like this but can't glean what I want from all the clever answers.
Here's the code:
TEST1.php
<FORM ACTION="HandleNewUser.php" METHOD=POST>
Username <INPUT TYPE=TEXT NAME="Username" SIZE=15><BR>
Password <INPUT TYPE=PASSWORD NAME="Password" SIZE=15><BR>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
HandleNewUser.php
<?php
session_register("Username");
// register the "username" variable and give output.
if (session_register("Username")) {
echo("User field set to $Username.");
} else {
echo("Could not set the session variable!");
}
if (($Username) && ($Password)) {
print ("Your request was successfully processed!<BR>\n".$Username);
} else {
print ("Please enter a Username and Password!\n");
}
//continues all same page
<FORM ACTION="Page3.php>" METHOD=POST>
Hair Colour <INPUT TYPE=TEXT NAME="HairColor" SIZE=15><BR>
Age <INPUT TYPE=PASSWORD NAME="Age" SIZE=15><BR>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</FORM>
</BODY>
</HTML>
Page3.php
<?php
if (($HairColor) && ($Age)) {
print ("Your request was successfully processed.. ".$Username);
} else {
print ("Please enter a hair color & age\n");
}
?>
</body>
</html>
Page3 is where I get no more values out of the session. Why? This is doing my nut in!. Thanks anyone who can help.