Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Comparison of ajax Authentication user names in tp Framework

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Database design random design anyway, the user can deposit it!

The body tp background method is simplified:

/ / user Authentication function checknm ($name) {$info = D ('user')-> where ("user_name =' $name'")-> find (); / / dump ($info); die; $flag =''; if ($info) {echo 1;} else {echo 2;}}

Backend returns 1 and 2

The front-end ajax part receives the status of 1 and 2 with data

Of course, the reception of data mainly depends on what format of data type you transmit in the background! This everyone can Baidu ajax!

.msg {color:gray;} .msg2 {color:#ff3333 } function checkname () { Var name = document.getElementById ('User_username'). Value $.get ('/ tpTest/index.php/User/checknm', {name:name}, function (data) {/ / alert (name)) If (data = = 1) {var nm = document.getElementById ('span1'); NM [XSS _ clean] =' username exists'; nm.className = "msg2" } if (data = = 2) {var nm = document.getElementById ('span1'); NM [XSS _ clean] =' user can use' Nm.className = "msg" })} User name

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report