Let me start by saying I am new to php. I have a lot of Javascript and html experience, but now I'm lost. I have been searching this and other forums for this and while it seems similar to other questions, there is something very odd here. The pages I am doing are forms for testing ideas for a registration page.
The first form (register.php) echo's the POST back to itself for validation. If validation fails it redisplays the form with added text at the top to say "please fill in all required fields". This works great. I even got it to keep the data (although that code was removed during troubleshooting). This page has a session_start(); and a $SESSION=$POST; as the first and second lines. I have added 1 'test' SESSION variable with $SESSION['test'] = 5;.and I have also added text to see the session_id. Even a print_r($SESSION);. These are set to show if it is reloaded due to failed validate. After submit it all works and displays the test and session variables from the form fine. (I leave 1 field blank to force a fail). All seems fine. I HAVE session id, session variables and post variables.
register.php
<?php
session_start();
header("Cache-control: private"); //ie6 fix
$SESSION = $POST;
$_SESSION['test'] = 5;
if($POST["submit"])
{
if (!$POST["fname"] || !$POST["lname"] || !$POST["address"] || !$POST["city"] || !$POST["state"] || !$POST["zip"] || !$POST["hphone"] || !$POST["wphone"] || !$POST["email"])
{
$error = "Please check your required fields";
}else{
header('LOCATION: display.php');
}
}
?>
-html here-
The header line take syou to the next page which starts with session_start();. Now the problem: IT WAS WORKING. This page pulls variables out of $POST, and I have used $SESSION. Then id addslashes the data and places the data into MySQL. It also displays the variables. I added a stripslashes is all and it failed. I took out the stripslashes and still failed. So I added the session_id code. For a while both pages were diffferent id's. Now they are the same id but not even the test session variable works. All code works if I POST direct to the display page.
top of display.php
<?php
session_start();
header("Cache-control: private"); //ie6 fix
if($SESSION['test']){
echo 'GOOD';
echo $SESSION['test'];
}ELSE
{
echo 'BAD';
}
// extract form data
-DATABASE CODE IS HERE-
?>
I added the test just see if a fixed session variable would come over, but nooooo. Not for me.
How can this be? Same ID and the SESSION's display indicate they are set. Yet I get empty records inserted into mysql. I tried everything to avaiod this request, but I am lost. One other thing is the "refresh". It causes the record to entered again. I know redirect to another page. No way to trap the refresh?
Anyway, I really thank you all in advance for any ideas.
Razz