Hi,
I have a weird problem I hope some of you can solve for me...
I'm creating a section of a site where people can apply for a login. I need some information from them so I made a form which they can fill out. After they pushed a submit button, a script checks to see if they made any mistakes. If so, the same page is reloaded with the retained application information and a few error messages.
What I've created is in principle a loop between two php-scripts. The first creates the form, fills the fields with retained information (if there is any) and generates error messages (if there are any) in the form to be noticed by the user.
The second script is called when the user had pressed submit and checks if there are errors in the user-input. If so, the user is redirected to the previous script.
In the second script a class is created to store the answers and errors. This class also contains the function to check if there are errors.
So far so good, you think....
The structure works perfectly after submitting the information a second time. The first time I press submit nothing is retained, not even the PHPSESSID
I've tried a lot of different configurations and created a very basic tryout version, which does the very same:
<b> first script file: </b>
<?
session_save_path("c:\temp\");
session_start();
if(!$PHPSESSID)
{
session_register('tester');
}
else if(!$tester)
{
session_register('tester');
}
?>
<?
echo "<head><title>testje</title></head><body>";
echo "<form method=\"post\" action=\"at.php\">
<input type=text name=test value=\"$tester\">
<input type=submit>
</form>";
echo "</head>";
?>
<b> second script file </b>
<?
session_save_path("c:\temp\");
session_start();
if(!PHPSESSID)
{
session_register('tester');
}
else if(!$tester)
{
session_register('tester');
}
?>
<?
if(! isset($tester))
{
$tester = $test;
echo ("<meta http-equiv=\"Refresh\" content=\"0; url=http://212.120.116.219/dinnerplaza/test/arraytest.php\">");
//header('location: http://212.120.116.219/dinnerplaza/test/arraytest.php');
exit;
}
?>
<head>
<title>
test
</title>
</head>
<body>
<? echo $tester; ?>
</body>
If you want to try it out you need to change the adress of the redirection rule to where the first script file is located.
For extra information:
I'm running this on windows (ME) with an Apache web server.
I've tried to start the session without the if(..) else if(...) structure, with only the session_start() and session_register(...) functions... But the result was the same.
If I fill in a string and press submit, the page comes back with no value in the input field. If do it a second time (with a different input string) the page also comes back but with the second input string as value (which is the purpouse of the scripts). Press submit again and you will see a page with only the second input as text. This is supposed to be happening but it's supposed to be happening with the first input string.
Can anybody help me with this problem??
Many thanks!!
Jasper.