Home  >  Article  >  Backend Development  >  ajax verification username and password, ajax verification username_PHP tutorial

ajax verification username and password, ajax verification username_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:23:251043browse

ajax verifies user name and password, ajax verifies user name

<span><span> 1</span>     <span>var</span> user = form.name.<span>value;
</span><span> 2</span>     <span>var</span> password = form.password.<span>value;
</span><span> 3</span>     <span>var</span> url = "chkname.php?user="+user+"&password="+password;<span>//</span><span>以前只知道ajax用于对用户名的检测,原来还可以对密码进行检测。</span>
<span> 4</span>     xmlhttp.open("GET",url,<span>true</span><span>);
</span><span> 5</span>     xmlhttp.onreadystatechange = <span>function</span><span>(){
</span><span> 6</span>     <span>if</span>(xmlhttp.readyState == 4<span>){
</span><span> 7</span>             <span>var</span> msg = xmlhttp.<span>responseText;
</span><span> 8</span>             <span>if</span>(msg == '1'<span>){
</span><span> 9</span>                 alert('用户名或密码错误!!'<span>);
</span><span>10</span>                 form.password.<span>select();
</span><span>11</span>                 form.check.value = ''<span>;
</span><span>12</span> <span>                code(form);
</span><span>13</span>                 <span>return</span> <span>false</span><span>;
</span><span>14</span>             }<span>if</span>(msg == "3"<span>){
</span><span>15</span>                 alert("用户名被占用,请重新输入!"<span>);
</span><span>16</span>                 <span>return</span> <span>false</span><span>;
</span><span>17</span>             }<span>else</span><span>{
</span><span>18</span>                 alert('欢迎光临'<span>);
</span><span>19</span>                 location.<span>reload();
</span><span>20</span> <span>            }
</span><span>21</span> <span>        }
</span><span>22</span> <span>    }
</span><span>23</span>     xmlhttp.send(<span>null</span><span>);
</span><span>24</span>     <span>return</span> <span>false</span>;</span>

php implements user name and user verification in the database through ajax

The first step requires a jq js file
9c217573965777fe7e858ef7fe4e3799
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
c014038dc7c13fc2826e15efd7a2a216
b2386ffb911b14667cb8f0f91ea547a7Login6e916e0f7d1e588d4f442bf645aedb2f
74df753ddf0f071f3ec85edaf13215f9baseUrl ?>/public/js/jq1.7.js" >2cacc6d41bbb37262a98f745aa00fbf0
1a24b17f85e15c83fc29b7760e40bfcb
$(document).ready(function(){
$("#submit").click(function() {
if( $("#uname").val() == "" || $("#upas").val() == "" ){
alert("Username or password Cannot be empty");
return false;
}else{
$("#showerrormessage").load(
'ac16d2860bd74e5b9f1019bec2b4bd2fbaseUrl ?>/ index/login',
{uname:$("#uname").val(),upas:$("#upas").val()},
function(data){
if (data == 1){
$("#showerrormessage").html('login success!!!');
}else{
$("#showerrormessage").html('login error~~~');
}
}
);
}
});
});
2cacc6d41bbb37262a98f745aa00fbf0
3c7b149cc556f883a18b3c490b028d4e
6c04bd5ca3fcae76e30b72ad730ca86d
26ab95818f4c235dd39cfad95490f262
Username:

I want to use jsp+ajax technology to implement user name and password verification for login, mainly using javascript

I know Ajax. But I am only half-experienced in JSP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/836505.htmlTechArticleajax verifies user name and password, ajax verifies user name 1 var user = form.name. value; 2 var password = form.password. value; 3 var url = "chkname.php?user="+user+"password="+password;...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP implements the method of obtaining the color value of an image, _PHP tutorialNext article:PHP implements the method of obtaining the color value of an image, _PHP tutorial

Related articles

See more