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'; } ?>

?>


php jquery html

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Know Everything About HTML With HTML Experts

HTML Assignment Help Australia @30% OFF from Sample Assignment, with Our Best HTML assignment help experts. Get HTML homework help online at affordable price. 100% Plag free assignment solution.

Commonly Used HTML Tags with Examples

HTML tags are keywords used in HTML to display web-pages with certain properties. They are further used for defining HTML elements. An HTML element consists of a starting tag.

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...

All You Need To Know About HTML Forms

This article provides an introduction to styling forms with CSS, including all the basics you might need to know for basic styling tasks.

How to Load XML data in jQuery UI autocomplete with PHP

You can load XML data if you have available. In this tutorial, I show how you can load XML file data in jQuery UI autocomplete using AJAX and PHP.