For an odd reason that I cannot figure out on my own, when a user
attempts to log-in on my Log-In page, they must press the submit
button twice.
They fill out their credentials (username, password), then press
submit. The postdata is indeed sent the first time around. I used echo
to show the values. Then a second submit is required for the if
control structor to initiate the log-in sequence. This happens on
index.php, the login.php page is included into index.php.
This if statement looks for a session variable named "validated" :
// On index.php
if ($_SESSION["validated"] == true) {
// do stuff when the user is logged in (include files, ect)
} else {
// include the login page
}
However, the login page has a control structor looking for the
presence of a $_POST variable...
// On login.php
if ($_POST["submitted"]) {
// initiate validation function, return value into a variable
if (/* Authentication variable returns true */) {
$_SESSION["validated"] = true;
}
}
I bet the issue lies in the order of the predefined variables, right?
In my PHP.ini, the variables_order setting is set it it's default of
EGPCS; Evironment, Get, Post, Cookie, Server. Is it that Post
variables are being sent in the login.php to check if "submitted" is
true, then the session variables sent to index.php on the second
submissial?
Thanks for your help! If I haven't made myself clear enough, or
something's not right, I will be more than happy to clarify myself!
attempts to log-in on my Log-In page, they must press the submit
button twice.
They fill out their credentials (username, password), then press
submit. The postdata is indeed sent the first time around. I used echo
to show the values. Then a second submit is required for the if
control structor to initiate the log-in sequence. This happens on
index.php, the login.php page is included into index.php.
This if statement looks for a session variable named "validated" :
// On index.php
if ($_SESSION["validated"] == true) {
// do stuff when the user is logged in (include files, ect)
} else {
// include the login page
}
However, the login page has a control structor looking for the
presence of a $_POST variable...
// On login.php
if ($_POST["submitted"]) {
// initiate validation function, return value into a variable
if (/* Authentication variable returns true */) {
$_SESSION["validated"] = true;
}
}
I bet the issue lies in the order of the predefined variables, right?
In my PHP.ini, the variables_order setting is set it it's default of
EGPCS; Evironment, Get, Post, Cookie, Server. Is it that Post
variables are being sent in the login.php to check if "submitted" is
true, then the session variables sent to index.php on the second
submissial?
Thanks for your help! If I haven't made myself clear enough, or
something's not right, I will be more than happy to clarify myself!
Comment