Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4171620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:27:58+00:00 2026-05-21T00:27:58+00:00

Assuming I have a block of code like this on a login page: <form

  • 0

Assuming I have a block of code like this on a login page:

<form action="login_action.php" method="post">
    <div id="account">
        <div class="form-label">Username:</div>
        <div class="form-input"><input name="username" type="text" /></div>
        <div class="form-label">Password:</div>
        <div class="form-input"><input name="password" type="password" /></div>
        <div class="form-submit"><input type="submit" value="Submit" /></div>
    </div>
</form>

The login_action file queries the database with the given credentials and if they are correct performs $_SESSION['username'] = $username;

This works fine. However, if the user provides incorrect credentials, ideally the page would not redirect and instead it would display an error message on the page on the line before username. This is the part I am confused on how to tackle.

Would I instead have to capture the submit button press with JQuery and post the user credentials to the php file with AJAX? This would then get rid of the form on the login page. I suppose then I could return a string specifying whether or not the credentials were valid and if not, it would append a message to the account div that the credentials were incorrect.

Would that be the standard approach to this sort of problem? Since recently discovering AJAX I am using it for almost everything and I’m not sure if in this case it is the ideal solution. Overriding the submit button’s default behavior and removing the form seems kinda hacky to me but I’m not sure. Is this how SO would solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T00:27:59+00:00Added an answer on May 21, 2026 at 12:27 am

    What I normally do is, use condition statement & redirect back to form if the password is incorrect. Assume your form page is form.php, the redirect could be form.php?status=password.
    Then you can display an error message in your form

    if ($_GET['status'] == 'password')
       echo "Incorrect Password";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have a code block like this : //Assuming s is a stream:
I have this code, and for some reason my $.post function fires twice in
I have a block of uncommented code I'm trying to understand. The comments are
I have some code that does Bitmap manipulation using the LockBits method and accessing
This may well have come up before but the following code is taken from
Let's say you have a piece of code like: resource = allocateResource(); try {
(I have tagged this question as Python as well since I understand Python code
I have the following URL format: example.com/page/m6aoeh/embed I want to block any bots from
I have a list of strings.. each one looks similar to this: \n\t\BLOCK\,\HEADER-\\r\n\t\t\NAME\,\147430\\r\n\t\t\REVISION\,\0000\\r\n\t\t\DATE\,\11/11/10\\r\n\t\t\TIME\,\10:03:47\\r\n\t\t\PMABAR\,\\\r\n\t\t\COMMENT\,\\\r\n\t\t\PTPNAME\,\0805C\\r\n\t\t\CMPNAME\,\0805C\\r\n\t\BLOCK\,\PRTIDDT-\\r\n\t\t\PMAPP\,1\r\n\t\t\PMADC\,0\r\n\t\t\ComponentQty\,4\r\n\t\BLOCK\,\PRTFORM-\\r\n\t\t\....(more).... What
Assuming I have only the class name of a generic as a string in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.