-4

Hello i'm trying to do a login form query code that valides if my username and password is entered correctly with the username and password: New_Username and 123456789,i tried with php but for some reason the php code doesn't work in VS code code:

$(document).ready(function () {
    $("#login").click(function () {
        var email = $("#email").val();
        var password = $("#password").val();
        // Checking for blank fields.
        if (email == '' || password == '') {
            $('input[type="text"],input[type="password"]').css("border", "2px solid red");
            $('input[type="text"],input[type="password"]').css("box-shadow", "0 0 3px red");
            alert("Please fill all fields...!!!!!!");
        } else {
            $.post("login.php", {
                    Username: New_Username,
                    password1: 123456789
                },
                function (data) {
                    if (data == 'Invalid Email.......') {
                        $('input[type="text"]').css({
                            "border": "2px solid red",
                            "box-shadow": "0 0 3px red"
                        });
                        $('input[type="password"]').css({
                            "border": "2px solid #00F5FF",
                            "box-shadow": "0 0 5px #00F5FF"
                        });
                        alert(data);
                    } else if (data == 'Email or Password is wrong...!!!!') {
                        $('input[type="text"],input[type="password"]').css({
                            "border": "2px solid red",
                            "box-shadow": "0 0 3px red"
                        });
                        alert(data);
                    } else if (data == 'Successfully Logged in...') {
                        $("form")[0].reset();
                        $('input[type="text"],input[type="password"]').css({
                            "border": "2px solid #00F5FF",
                            "box-shadow": "0 0 5px #00F5FF"
                        });
                        alert(data);
                    } else {
                        alert(data);
                    }
                });
        }
    });
});

is this the good code for login form query that i mentioned it gives an error saying "dom.js:1 Uncaught ReferenceError: $ is not defined at dom.js:1",also the login form and validation not working how i fix this error and code?

ADyson
  • 44,946
  • 12
  • 41
  • 55
  • 3
    This is one of the most Google-able errors in the world. When you get an error, you're almost never the first person to experience it...always research – ADyson May 25 '21 at 08:04
  • i tried the way you mentioned in the question that is similar but it still gives error even if i use the google chrome script link – Claudiu Piturca May 25 '21 at 08:10
  • What exact script tag did you use? Show us. And do you still get the same error, or a different one? – ADyson May 25 '21 at 08:15

0 Answers0