Hey! I got a little login script, like when user presses the button it sends the form and does the php code to check the account, what I want to do is if the password or username is wrong, that the user will be redirected to loginpage and I want to display message with javascript that the password/username was wrong. How should I actually do this?
Silvershaft
2
Junior Poster
Recommended Answers
Jump to PostYou could use ajax to do the login check and echo wether or not login was successful with an if statement.
So something along these lines
// Varibles that hold userinfo var username = $('#UserName').attr('value'); var password = $('#UserPassword').attr('value'); $.ajax({ type: "POST", url: "php/process_login.php", data: "username=" …
Jump to PostNa, thats just to get an error if that ajax isn't sent succesfully. We gonna add the error to the error class. View below (read comments)
<html> <head> <title>Login</title> <script src="
Jump to PostThats easy with jquery, could just chain some animations. E.g
var username = $('#username').attr('value'); var password = $('#password').attr('value'); alert(username); $.ajax({ type: "POST", url: "check.php", data: "username=" + username + "& password=" + password, success: function() { alert('Success') }, error: function() { alert('failure'); }, function(data) { $('.error').slideDown('slow').html(data); } …
All 9 Replies
macneato
29
Posting Pro in Training
Silvershaft
2
Junior Poster
Kiruba Priya
0
Newbie Poster
macneato
29
Posting Pro in Training
Silvershaft
2
Junior Poster
Silvershaft
2
Junior Poster
macneato
29
Posting Pro in Training
Silvershaft
2
Junior Poster
Silvershaft
2
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.