473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

User Must Submit Twice For Data to Send

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!
Jul 17 '05 #1
1 2878
"Daniel" <ul*********@hotmail.com> wrote in message
news:9c*************************@posting.google.co m...
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!


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
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nicolas Keller | last post by:
Hi! I'm used to have Mozilla for testing my PHP sites when I'm coding. The site's nearly finished, now I've made a test with the Internet Exlporer... guess what... failed. The problem: I'm...
3
by: Vincent M. | last post by:
Hello, I have a form which allow to submit a file, I'd like to block the submit buton once it has been clicked, so I tried: function SubmitNow(item){ if(item.value=="Please wait") { return...
3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
11
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP...
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
8
by: Ian Davies | last post by:
Hello I am trying to run a few INSERT queries only if the user clicks 'continue' in a <a href> The queries takes variables created from SELECT queries. I have tried to acheive this by putting The...
3
by: Patrick Olurotimi Ige | last post by:
How can i send LOGON_USER or User.Identity.Name to the Database? I'm working on a survey which is intranet based with Windows Authentication. I can get the current user by calling LOGON_USER or...
2
by: b3t1m0s | last post by:
Hi everyone here! I have a special case and I want to ask can I realize this in JavaScript/AJAX. The case is: I have html submit form that should send data to php file. When submit button is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.