User login form using jquery ajax not working properly, not directing to any page

User login form using jquery ajax not working properly, not directing to any page

I'm trying to create a login form with jquery ajax by taking user details from "reg" table in database. But It'snot working .I want to enter anothe page called menu.php after login. Nothing is showing when i click login button Can anyone help please

I'm trying to create a login form with jquery ajax by taking user details from "reg" table in database. But It'snot working .I want to enter anothe page called menu.php after login. Nothing is showing when i click login button Can anyone help please

<script type="text/javascript">
         $(document).ready(function(){

$('#loginForm').submit(function(event) { event.preventDefault(); $.ajax({ url: "logindata.php", type: "POST", data: { username: $("#username").val(), password: $("#password").val() }, success: function(response) { if(response == 1) { window.location.href = "menu.php"; } else { $("#errorMessage").html("Attempting Login..."); } } });

       });
});
        &lt;/script&gt;

Here is the HTML:

<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<center><b>Login</b></center><br>
                <form name="loginForm" id="loginForm"  action="" method="post" align="center">
       Username:    <input type="text" name="username" id="username"  /><br><br>
       Password:    <input type="password" name="password" id="password"  /><br><br><br>
                    <input type="submit" name="login" id="login" value="Sign In" />
                </form>

Mysql query page:

<?php
$conn =mysqli_connect("localhost", "root", "", "project");

$f="SELECT * FROM reg WHERE uname='" . $_POST["username"] . "' and password = '". $_POST["password"]."'"; $result = mysqli_query($conn,$f); $row = mysqli_fetch_assoc($result); if( $row[0] > 0 ) { echo 'true'; } else { echo 'false'; } ?>

?>


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!

How to Include PHP in HTML

Welcome to this article on how to use PHP in HTML! Here, we try to get specific about exactly how PHP and HTML interact, at the level of a specific .php file. In other words, how do you actually include PHP in HTML, and what rules can and can’t you follow in weaving PHP and HTML together?

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...