Incorrect username / password message and redirect

wrong username or password message
invalid email or password message
password wrong message
how to show invalid username'; $password in php
invalid login credentials message
how to display error message in login page using php
invalid login message
invalid login attempt message

Creating a Client Login area. I have my log in form in a clientLogin.html:

       <form name="ClientLogin" method="post" action="login.php"> <br>
            <p>
             <label for='Username'>Username</label> <br>
            <input type="text" name="username" />
            </p>
            <p>

            <label for='Password'>Password</label> <br>
            <input type="password" name="password" />
            </p>
            <br>
            <input type="submit" value="Submit" />

        </form>

If the username & password combination are incorrect I want to redirect to this page adding a message saying "incorrect username/ password please try again". This is the code from login.php:

<?php


//Connect to the database
    require('db.php');

    $user = mysql_real_escape_string($_POST["username"]);
    $pass = mysql_real_escape_string($_POST["password"]);

    $clientdata = mysql_query("SELECT * FROM Users WHERE username='$user' and            password='$pass'")
    or die (mysql_error());

    $data = mysql_fetch_array($clientdata, MYSQL_ASSOC);

    if(mysql_num_rows($clientdata) == 1){

session_start();


$_SESSION['username'] = $user;


header('Location: profile.php');

    }else{
header('Location: clientLogin.html');
    }

I expect the clientLogin.html files needs changing to a .php file. other than that I am stumped. Any guidance would be greatly appreciated.

You need to change extension of clientLogin.html from .html to .php

Change header('Location: clientLogin.html'); to header('Location: clientLogin.php');

Add this part of code at the top of your clientLogin.php page:

<?php 
session_start();
if(empty($_SESSION['username'])) {
 echo 'incorrect username/ password please try again.' ;
}
?> 

   

How can I redirect user after entering wrong password?, wp_login_form() creates a form with an action attribute of site_url/wp-login.php , which means that when you click the submit button the form is posted to� If the username & password combination are incorrect I want to redirect to this page adding a message saying "incorrect username/ password please try again". This is the code from login.php:

You can set a SESSION flag and when calling ClientLogin.

    $_SESSION['loginerror'] = 1;

in ClientLogin.php

    if ($_SESSION['loginerror'] > 0) {
      /* Display Appropriate Error message */
    }

Custom login redirects to wp-admin on wrong password , While coding a custom login page, one needs to take care of the errors, else WordPress would redirect the page to /wp-admin or wp-login.php on wrong� Every time I try to log into my account I get a message "incorrect username or password". I then go through the password reset procedure and can go to my account. after logging out I get the same "incorrect username or password" message when I try to log in again. This happens everytime I log out an

you should use exit(); after redirecting to other file like..

header('Location: profile.php');
exit();

you please use mysqli instead of mysql .its not going to be supported by new version of php.

Redirect URL after wrong password, This is confusing, because the user only sees the error-message if he/she scrolls down to the login-form. I created an anchor at the login-form, but I didn't find any� Function login_failed () –when your entered an incorrect username and password, then this function redirects you back to a custom login page with an error message of invalid username and password.

How to Fix WordPress Login Page Refreshing and Redirecting Issue, We often get messages from our users that their WordPress login page keeps And no, I did Duration: 4:56 Posted: 10 Mar 2020 FreshSparks is a brand agency specializing in strategy, design and digital marketing solutions. We can help you build a successful new online presence, or upgrade an existing website.

Elementor Login Form, Redirecting user to custom login page with an error message (Ex: Wrong username or password, please try again"). Describe alternatives� Disclaimer: This site is started with intent to serve the ASP.Net Community by providing forums (question-answer) site where people can help each other. The content posted here is free for public and is the content of its poster.

Salesforce Error: INVALID_LOGIN: Invalid username, password , Salesforce Error: INVALID_LOGIN: Invalid username, password, security token, user not active, or user locked out. Download the PDF of this article. home.php. When login user is valid then redirect the user to this page. If the $_SESSION['uname'] variable is not initiated then redirect to index.php webpage.. Destroy $_SESSION['uname'] on logout button click and redirect to index.php.

Comments
  • What error are you getting? Other than the first line which should start with // since that's a comment
  • You could use something to the affect of if(($user["user"] == $login["user"]) && ($user["pass"] == $login["pass"])) { echo "You are logged in"; } else{ echo "You are not logged in";
  • @Fred-ii- numRow is also a good solution
  • @FaceOfJock Yes indeed, you're right. I only provided the OP a quick example that I have on file.
  • We need more details about error because i think this code is correct
  • Hi, Sorry I think I have confused matters, I have just edited the original question as the redirect currently goes back to the clientLogin.html, there is no clientlogin.php.
  • @SJBenton check my answer
  • Hi, sorry I'm quite new to this! I have used your solution 2, copied the code into the file now called clientLogin.php, but now the first time you visit the page to log in the error message comes up, I only want it to come up after a failed login attempt.
  • @SJBenton , create a file clientLogin.html ,put the html code in the first solution , that's all
  • That way would produce a static message, what I want is to go back to the original form (clientlogin.php) so they can try again, with a message appearing on this page, saying that the details they entered the first time were incorrect.
  • so the top bit goes in login.php inside else{ and the second bit goes in what was clientLogin.html (now clientLogin.php) like this <?php if ($_SESSION['loginerror'] > 0) {echo "incorrect login details";}?>
  • ClientLogin is name of form
  • @ClientLogin yes but this is not the problem
  • @RajeevRanjan Changing the OP's file extension to .php doesn't explain what is required in order for it to work properly. Your answer does not answer nor explain these details.