I wrote a form. In php, I want to directly connect to the backend database for verification by clicking on login. If it is correct, it will be adjusted directly to the next page. If it is incorrect, the information about the wrong account and password will be displayed directly on the login page. No. Jump back and forth.
I read a lot of them. First jump to the verification php page. If it is correct, take the next step. If it is not correct, it will be very troublesome to open it again to log in to php.
Does anyone know?
Exit() if error occurs; try
If the front-end and back-end are separated, use ajax. If it is PHP+HTML, I will give you a code reference
<?php
@$username = $_REQUEST['username']; //Get the account number submitted on this page
@$password = $_REQUEST['password'];//Get the password submitted on this page
$status = false ;//Define a state
if (isset($username) || isset($password)) {
//If both the username and password are available, execute the verification logic, If there is an error, change $status to an error message, such as incorrect account and password
}
?>
<html>
<body>
<!-- The action submission address of the form is the PHP file of the current page-->
<form action="/login.php" method="post">
<?php if ($status !== false ) { echo "<div>".$status."</div>" } ? >
##</form>
<body>
</html>Just use ajax, the page will not switch.