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! 1 2891
"Daniel" <ul*********@ho tmail.com> wrote in message
news:9c******** *************** **@posting.goog le.com... 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.p hp")
3) else show login form This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 using a form that submit's (POST) its data via three
different image buttons (depending on which button you click,
something different should happen):
|
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 false ;
} else {
item.value="Please wait" ;
|
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 three
> different image buttons (depending on which button you click,
> something different should happen):
>
> <form action="id.php" method="post" name="form2">
|
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.
|
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
pages for processing. The problem is, the user inputs can
become very complex, and the way this application was developed,
the inputs are all concatenated into monstrously long strings
of text that are then submited as <hidden> inputs in HTML forms...
| |
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 what I'd like to have happen :
|
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 INSERT queries into a function at
the top of my php file and having the SELECT queries below it. I have a
message that pops up that includes a link to the function but I cant get
this to work and am not sure of the best approach. Can anyone help?...
|
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 User.Identity.Name !
But i want to pass(the current user) to a table in DB!
I was thinking of ussing hidden textboxes like so :-
Is it a good approach..
Any ideas appreciated!
|
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 pressed a "popup" or modal windows must be displayed and user must click in page (ex. image), and page should open a new window (from image hyperlink ex.) and return to the main page (submit form) to finally send data to php file.
Is this realized in...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |