Example code for ajax verification of username and password
This article mainly introduces the example code of ajax verification user name and password in detail. Interested friends can refer to it
The example of this article introduces the specific code of ajax verification user name and password. , for your reference, the specific content is as follows
1.ajax main part
var xmlrequest; function createXMLHttpRequest(){ if(window.XMLHttpRequest){ xmlrequest=new XMLHttpRequest(); } else if(window.ActiveXObject){ try{ xmlrequest=new ActiveXObject("Msxm12.XMLHTTP"); } catch(e){ try{ xmlrequest=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){} } } } function login(){ createXMLHttpRequest(); var user = document.getElementById("yhm").value; var password = document.getElementById("mm").value; if(user==""||password==""){ alert("请输入用户名和密码!"); return false; } var url = "check.php?user="+user+"&password="+password; xmlrequest.open("POST",url,true); xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlrequest.onreadystatechange = function(){ if(xmlrequest.readyState == 4){ if(xmlrequest.status==200){ var msg = xmlrequest.responseText; if(msg=='1'){ alert('用户名或密码错误!'); user=""; password=""; return false; } else{ window.location.href="index1.html"; } } } } xmlrequest.send("user="+user+"&password="+password); }
2.html code
<input placeholder="用户名" autofocus="" type="text"name="username"> <input placeholder="密码" type="password" name="password"> <button id="dl" onclick="login()">登录</button>
3. Sha1 encryption is used here, just change your password and database name to your own
<?php $yhm1=$_POST['user']; $mm1=$_POST['password']; @ $dp=new mysqli('localhost','root','你的密码','你的数据库名称'); $yhm2=sha1($yhm1); $mm2=sha1($mm1); $query="select * from zhuce where yhm='$yhm2' and mm='$mm2'"; $result=$dp->query($query); $num=$result->num_rows; if(!$num){ echo "1"; } $dp->close(); ?>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Ajax file upload successfully solves browser compatibility issues
laypage front-end paging plug-in implements ajax asynchronous paging
Ajax method of sending and receiving binary byte stream data
The above is the detailed content of Example code for ajax verification of username and password. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When using Win11 system, sometimes you will encounter a prompt that requires you to enter the administrator username and password. This article will discuss how to deal with this situation. Method 1: 1. Click [Windows Logo], then press [Shift+Restart] to enter safe mode; or enter safe mode this way: click the Start menu and select Settings. Select "Update and Security"; select "Restart Now" in "Recovery"; after restarting and entering the options, select - Troubleshoot - Advanced Options - Startup Settings -&mdash

Wireless networks have become an indispensable part of people's lives in today's digital world. Protecting the security of personal wireless networks is particularly important, however. Setting a strong password is key to ensuring that your WiFi network cannot be hacked by others. To ensure your network security, this article will introduce in detail how to use your mobile phone to change the router WiFi password. 1. Open the router management page - Open the router management page in the mobile browser and enter the router's default IP address. 2. Enter the administrator username and password - To gain access, enter the correct administrator username and password in the login page. 3. Navigate to the wireless settings page - find and click to enter the wireless settings page, in the router management page. 4. Find the current Wi

Wireless networks have become an indispensable part of our lives with the rapid development of the Internet. In order to protect personal information and network security, it is very important to change your wifi password regularly, however. To help you better protect your home network security, this article will introduce you to a detailed tutorial on how to use your mobile phone to change your WiFi password. 1. Understand the importance of WiFi passwords. WiFi passwords are the first line of defense to protect personal information and network security. In the Internet age, understanding its importance can better understand why passwords need to be changed regularly. 2. Confirm that the phone is connected to wifi. First, make sure that the phone is connected to the wifi network whose password you want to change before changing the wifi password. 3. Open the phone’s settings menu and enter the phone’s settings menu.

This article will explore how to solve the problem of wrong password, especially the need to be careful when dealing with BitLocker warnings. This warning is triggered when an incorrect password is entered multiple times in BitLocker to unlock the drive. Usually, this warning occurs because the system has a policy that limits incorrect login attempts (usually three login attempts are allowed). In this case, the user will receive an appropriate warning message. The complete warning message is as follows: The password entered is incorrect. Please note that continuously entering incorrect passwords will cause the account to be locked. This is to protect the security of your data. If you need to unlock your account, you will need to use a BitLocker recovery key. The password is incorrect, beware the BitLocker warning you receive when you log in to your computer

1. Download and install Xiaobai’s one-click system reinstallation tool on another computer, insert an empty USB disk to create a USB boot disk. For specific tutorials, please refer to: 2. Insert the USB boot disk into the computer that needs to change the password to restart, and press Start hotkey. Generally, the startup hotkey is one of F12, F8, F9, F10, and ESC. Then the startup interface appears, select the option of the USB disk and press Enter to enter. 3. Select [1] to start win10x64PE and press Enter to confirm. 4. Select the password modification tool on the desktop and double-click to open it. 5. Then a list of account names appears, select the account that needs to change the password and open it. 6. Click the Change Password command below, enter the new password twice, and then click OK to save the changes. 7. Finally, unplug the USB flash drive and restart the computer. Then it will be normal.

In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I

Wireless networks have become an integral part of people's lives in modern society. Or need to view saved passwords in WiFi list, sometimes we forget WiFi password, however. Mobile software came into being to solve this problem. To make it easy for you to master this magical tool, this article will introduce a software that can help you quickly unlock all WiFi passwords. 1. Powerful WiFi password unlocking tool - explore the wonderful world of WiFi password unlocking 2. Simple and easy-to-use interface design - convenient and fast operation methods 3. Supports multiple devices - meets the needs of different devices 4. Automatically Update - always keep the latest WiFi password 5. High-speed WiFi connection - easily cope with the simultaneous connection needs of multiple devices

Analysis of user password storage mechanism in Linux system In Linux system, the storage of user password is one of the very important security mechanisms. This article will analyze the storage mechanism of user passwords in Linux systems, including the encrypted storage of passwords, the password verification process, and how to securely manage user passwords. At the same time, specific code examples will be used to demonstrate the actual operation process of password storage. 1. Encrypted storage of passwords In Linux systems, user passwords are not stored in the system in plain text, but are encrypted and stored. L
