| re: User Must Submit Twice For Data to Send
"Daniel" <ultimatezzz@hotmail.com> wrote in message
news:9c4f3da0.0310100333.19400bf@posting.google.co m...[color=blue]
> 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!
>[/color]
I would move the login page/code into the 'index.php' page as that's
where you are calling it from anyway.
index.php
1) session_start()
2) login link
3) if $_SESSION["validated"] == true then enable stuff
4) else don't enable stuff
login.php
1) session_start()
2) if username && password == allowed then $_SESSION["validated"] = true
2a) header("index.php")
3) else show login form |