What is the best method to display error message in the same login form
I have a login.php file and a login_process.php file. My login form is in the first file and validation in the other. I do not know how to display error messages in the login form in login.php after validation in login_process.php.
I have been researching and below is what I've found :
(Note : I have multiple error messages and I use selection to display those messages)
- Using
header('Location:login.php?submit=conError')
to redirect to the login.php file and in that file, use$_GET
to retrieve the query - Using
header('Location:login.php#conError')
to redirect to the login.php and file in that file, uselocation.hash
in javascript to retrieve the fragment - By including login_process.php in login.php and declare some variables and use
PHP_SELF
to use those variables to display error - Some use global session variable
$_SESSION['error']
Which is better and safer? Which method does developer use the most? Can somebody help clarify? Is there a better way than ways mentioned above (in terms of security and optimum run time)?
javascript php html html5 session
add a comment |
I have a login.php file and a login_process.php file. My login form is in the first file and validation in the other. I do not know how to display error messages in the login form in login.php after validation in login_process.php.
I have been researching and below is what I've found :
(Note : I have multiple error messages and I use selection to display those messages)
- Using
header('Location:login.php?submit=conError')
to redirect to the login.php file and in that file, use$_GET
to retrieve the query - Using
header('Location:login.php#conError')
to redirect to the login.php and file in that file, uselocation.hash
in javascript to retrieve the fragment - By including login_process.php in login.php and declare some variables and use
PHP_SELF
to use those variables to display error - Some use global session variable
$_SESSION['error']
Which is better and safer? Which method does developer use the most? Can somebody help clarify? Is there a better way than ways mentioned above (in terms of security and optimum run time)?
javascript php html html5 session
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20
add a comment |
I have a login.php file and a login_process.php file. My login form is in the first file and validation in the other. I do not know how to display error messages in the login form in login.php after validation in login_process.php.
I have been researching and below is what I've found :
(Note : I have multiple error messages and I use selection to display those messages)
- Using
header('Location:login.php?submit=conError')
to redirect to the login.php file and in that file, use$_GET
to retrieve the query - Using
header('Location:login.php#conError')
to redirect to the login.php and file in that file, uselocation.hash
in javascript to retrieve the fragment - By including login_process.php in login.php and declare some variables and use
PHP_SELF
to use those variables to display error - Some use global session variable
$_SESSION['error']
Which is better and safer? Which method does developer use the most? Can somebody help clarify? Is there a better way than ways mentioned above (in terms of security and optimum run time)?
javascript php html html5 session
I have a login.php file and a login_process.php file. My login form is in the first file and validation in the other. I do not know how to display error messages in the login form in login.php after validation in login_process.php.
I have been researching and below is what I've found :
(Note : I have multiple error messages and I use selection to display those messages)
- Using
header('Location:login.php?submit=conError')
to redirect to the login.php file and in that file, use$_GET
to retrieve the query - Using
header('Location:login.php#conError')
to redirect to the login.php and file in that file, uselocation.hash
in javascript to retrieve the fragment - By including login_process.php in login.php and declare some variables and use
PHP_SELF
to use those variables to display error - Some use global session variable
$_SESSION['error']
Which is better and safer? Which method does developer use the most? Can somebody help clarify? Is there a better way than ways mentioned above (in terms of security and optimum run time)?
javascript php html html5 session
javascript php html html5 session
edited Nov 24 '18 at 4:19
Funk Forty Niner
1
1
asked Nov 24 '18 at 2:04
Tyson ReeseTyson Reese
11
11
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20
add a comment |
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20
add a comment |
2 Answers
2
active
oldest
votes
I think you should use session option which is better way to show messages as most frameworks like codeigniter laravel and cms like WordPress opecart uses this approach.
And the sending error in URL doesn't seems good for the look of the application. If this is not a case for you then go ahead and change.
But I think message that we want to show almost includes in every page so it is better idea toh use session you dont need to pass it in URL.
Use session to store after displaying use unset to remove the message.
And with that you also ensuring to get rid of the burden of different names of variables for message on each page. You have single session variable which will do it for your whole application.
add a comment |
I think sending the error in the URL is easy and it is used in many applications. Error message is not a sensitive information. I think you should try the first method.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454595%2fwhat-is-the-best-method-to-display-error-message-in-the-same-login-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you should use session option which is better way to show messages as most frameworks like codeigniter laravel and cms like WordPress opecart uses this approach.
And the sending error in URL doesn't seems good for the look of the application. If this is not a case for you then go ahead and change.
But I think message that we want to show almost includes in every page so it is better idea toh use session you dont need to pass it in URL.
Use session to store after displaying use unset to remove the message.
And with that you also ensuring to get rid of the burden of different names of variables for message on each page. You have single session variable which will do it for your whole application.
add a comment |
I think you should use session option which is better way to show messages as most frameworks like codeigniter laravel and cms like WordPress opecart uses this approach.
And the sending error in URL doesn't seems good for the look of the application. If this is not a case for you then go ahead and change.
But I think message that we want to show almost includes in every page so it is better idea toh use session you dont need to pass it in URL.
Use session to store after displaying use unset to remove the message.
And with that you also ensuring to get rid of the burden of different names of variables for message on each page. You have single session variable which will do it for your whole application.
add a comment |
I think you should use session option which is better way to show messages as most frameworks like codeigniter laravel and cms like WordPress opecart uses this approach.
And the sending error in URL doesn't seems good for the look of the application. If this is not a case for you then go ahead and change.
But I think message that we want to show almost includes in every page so it is better idea toh use session you dont need to pass it in URL.
Use session to store after displaying use unset to remove the message.
And with that you also ensuring to get rid of the burden of different names of variables for message on each page. You have single session variable which will do it for your whole application.
I think you should use session option which is better way to show messages as most frameworks like codeigniter laravel and cms like WordPress opecart uses this approach.
And the sending error in URL doesn't seems good for the look of the application. If this is not a case for you then go ahead and change.
But I think message that we want to show almost includes in every page so it is better idea toh use session you dont need to pass it in URL.
Use session to store after displaying use unset to remove the message.
And with that you also ensuring to get rid of the burden of different names of variables for message on each page. You have single session variable which will do it for your whole application.
answered Nov 24 '18 at 2:32
AkhileshAkhilesh
626
626
add a comment |
add a comment |
I think sending the error in the URL is easy and it is used in many applications. Error message is not a sensitive information. I think you should try the first method.
add a comment |
I think sending the error in the URL is easy and it is used in many applications. Error message is not a sensitive information. I think you should try the first method.
add a comment |
I think sending the error in the URL is easy and it is used in many applications. Error message is not a sensitive information. I think you should try the first method.
I think sending the error in the URL is easy and it is used in many applications. Error message is not a sensitive information. I think you should try the first method.
answered Nov 24 '18 at 3:53
Ashan SamarasingheAshan Samarasinghe
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454595%2fwhat-is-the-best-method-to-display-error-message-in-the-same-login-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@GoojajiGreg About your (suggestive) edit and the comment you left: "This question is PHP related only.". I beg to differ. The OP wants to display a message and it can be done with languages other than PHP including the ones the OP originally chose. The tags are relevant and I've added another, being "javascript" and "sessions", also being relevant to the question.
– Funk Forty Niner
Nov 24 '18 at 4:19
This question is too broad and probably opinion-based. In terms of security and sessions; look up "sessions middle-man" and "sessions security" on the Web.
– Funk Forty Niner
Nov 24 '18 at 4:20