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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:26:55+00:00 2026-06-12T22:26:55+00:00

i want check in my mysql database if the user enter the username and

  • 0

i want check in my mysql database if the user enter the username and password correctly and then go in the home.html, i have some javascript code that detect when the user click the login button, but i can’t understand how check in the database with javascript, i know how do that in php, but i can’t understand how call the php from the javascript or do it directly in the js code, this is some code:

the form in the html:

    <div id="password">
        <div class="input username"><input type="text" placeholder="User name" /></div>
        <div class="input password"><input type="password" placeholder="Password" /></div>
        <button>Log in</button>
        <a href="#" class="back">Back</a>
    </div>
</div>

then in my Login.js file i have this:

function forgot() {
//Se ho scritto la password allora fai l'animazione wobble, altrimenti vai in home.html
    if($("#password .input.password input").attr("value")!='') {
        $.notification( 
            {
                title: "Wrong password",
                content: "Just leave the password field empty to log in.",
                icon: "!"
            }
        );
        $("#password").removeClass().addClass("animated wobble").delay(1000).queue(function(){ 
            $(this).removeClass();
            $(this).clearQueue();
        });
        $("#password .input.password input").attr("value", "").focus();
    } else {
        document.location.href = "home.html";
    }
}

now for the login i detect only if the field are empty, but i want detect mysql database how i can check it? because i want if the user enter wrong username and password span a $notification alert, anyone can help me?

  • 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-06-12T22:26:57+00:00Added an answer on June 12, 2026 at 10:26 pm

    Please suppose your html form is like below:

    <input id="uname" name="uname" type="text" placeholder="User name" />
    <input id="pass" name="pass" type="password" placeholder="Password" />
    <button id="btn_login">Log in</button>
    

    And suppose php script named checkPassword.php is like below:

    <?php
        /*
          1.Retrieve post data : "uname" and "pass".
          2.Cehck if  user name and password is valid.
        */
        if( /* valid user name and password */ ){
            echo "OK";
        }else{
            echo "NG";
        }
    ?>
    

    The Javascript code could goes like below:

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script language="javascript">
    $(function() {
    // set a event handler to the button
      $("#btn_login").click(function() {
        // retrieve form data
        var uname = $("#uname").val();
        var pass = $("#pass").val();
    
        // send form data to the server side php script.
        $.ajax({
            type: "POST",
            url: "checkPassword.php",
            data: { uname:uname, pass:pass }
        }).done(function( data ) {
    
            // Now the output from PHP is set to 'data'.
            // Check if the 'data' contains 'OK' or 'NG'
            if (data.indexOf("OK") >= 0){
    
                // you can do something here
                alert("Login Successed.");
                location.href = "ok.html";
    
            }else if(data.indexOf("NG") >= 0){
    
                // you can do something here
                alert("Login Faild.");
                location.href = "ng.html";
            }
        });
      });
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple (non-secure) login-check from mysql database, where I have
I have a non-Drupal site which authenticates with a simple MySQL user database. I
I have created a user Sam with password mypass for my database db. How
I have a mysql database containing several items and I want to change top
I want to check the log in MySQL to see the queries that are
I want to check checkbox like $('#riderCheck').attr('checked','true') on some condition. but the problem is
I want to check in my application programmatically if user shutdown/restart/logoff the computer. I
I have a form that is sending data to a MySQL database and I
I have the following table in the database: id, username, email, old_ip, current_ip Everytime
I have one textbox basically the user is going to enter in a 9

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.