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 706837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:12:38+00:00 2026-05-14T04:12:38+00:00

The code below gets the username/password and runs it thru the backend.php script. <?php

  • 0

The code below gets the username/password and runs it thru the backend.php script.

<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#login_form").submit(function() {
                var unameval = $("#username").val();
                var pwordval = $("#password").val();
                $.post("backend.php", { username: unameval, 
                password: pwordval }, function(data) {
                    $("#status p").html(data);
                });
                return false;
            });
        });
    </script>
    </head>
<body>
<?php
    if(isset($_SESSION['user_session'])) {
        print '<p>user '.$_SESSION['user_session'].' logged in</p>';
    } else { ?>
        <form id="login_form" method="post">
            <p>Username: <input type="text" id="username" name="username" /></p>
            <p>Password: <input type="password" id="password" name="password" /></p>
            <p><input type="submit" value="Login" /></p>
        </form>
        <div id="status">
            <p></p>
        </div> <?php
    }?>

</body>
</html>

It authenticates the user properly, but what I want it to is hide the form once successful.

Here is what the page looks like before the form is submitted: http://grab.by/3hoH

Here is the page after the form was successfully submitted: http://grab.by/3hoR

I think I need to run some javascript to check for success, then if success, do not display form, if !success, display form.

I am unsure on how to do that, if that is the case.

backend.php code

<?php
session_start();
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once('adLDAP.php');
//header('Content-type: text/json');
$adldap = new adLDAP();

if(isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];  // associated password

    // connect to ldap server
    $authUser = $adldap->authenticate($username, $password);
    if ($authUser === true) {
        print "<p>authuser true</p>";
        $_SESSION['user_session'] = $username;

        if(isset($_SESSION['user_session'])) {
            print "<p>session is set</p>";
        }   
    }
    else {
      print "<p>User authentication unsuccessful</p>";
    }
}
?>
  • 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-14T04:12:38+00:00Added an answer on May 14, 2026 at 4:12 am

    You need to check the response to see if the login succeeded, and, if it did, remove the login form.

    You can remove the login form by writing

     $('#login_form').remove();
    

    To check whether the login succeeded, you should change your server-side script to return a JSON object that indicates whether the login succeeded and contains a message.
    For example:

    { success: true, message: "You have successfully logged in" }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below is the html code for TD which gets appended after matching
The code below gets me the ldap username and full name...I am a little
The code pasted below gets an exception on the line that says... InputStream in
I have an application that displays videos. The code below gets a list of
The code is listed below: @Document @XmlRootElement public class User { @Indexed(unique=true) private String
The code below gets the information i require from my database but is not
The code below gets the values I have entered for my report parameters in
The below code gets me the users in the group but it is returned
I'm sure this is something really simple... I have the code below... <script> function
In the code below, the value of prod is not 9,000,000; it gets a

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.