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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could probably achieve this with CSS. Assuming the list… May 16, 2026 at 6:14 pm
  • Editorial Team
    Editorial Team added an answer After having some search I found how to sign my… May 16, 2026 at 6:14 pm
  • Editorial Team
    Editorial Team added an answer Firstly you have named two different instances to "name1", secondly… May 16, 2026 at 6:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

The code below works great. I have a MySQL database that contains book titles
Using gcc 4.4.3 c89: I am just working on the following code below: I
the code below are all height=100%, it works fine in chrome but it displayes
I've got this code below, where I spawn several threads, normally about 7, and
I'm using the code below to to write to a file but at the
I have set my database fields username and email to unquie, when using the
Morning Everyone, I've been attempting to write an application that does some GETs from
I've written a Powershell script which will compare two databases and come up with
Consider the two implementations below, data.addRows([ ['2004', 1000], ['2005', 1170], ['2006', 660], ['2007', 1030]
I have an HTML page. I have created a frame using background repeat function.

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.