总结:
经过20多天的努力学习,把前段的课程都学完了,感觉时间过的很快,在前段,我基本看着老师前面写什么都,我都可以知道,下一步要做什么了,但是要自己写就写得慢,有时候会忘记代码,还是要都写多练,这是最快掌握,也是最踏实的方法,我一般晚上听完老师讲课,就会自己动手写上一个小时左右,然后第二天再看着回播,然后对照着写,有时候会超前老师写,着基本就是我的学习方法,还有,我有空余的时间就会看回以前的视频,以防忘记了太多,等于白学了。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h2>用户注册</h2>
<p>用户名:<input type="text" name="name"></p>
</body>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$('input').blur(function){
$.ajax({
//1请求的服务器资源
url:'api/demo1.php',
//2客户端请求类型(get post put )
type:'GET',
//3从服务器返回的数据格式:json html xml txt
// dataType:'json',
//4异地或者同步,true异步 false同步(浏览器锁定)
// async:'true',
//5发送的数据:string json ,序列化
data:'name'+$(':input').val,
//6成功回调函数success:function(msg status xhr){}
success:function(msg,status,xhr){
console.log(msg)
}
//错误回调函数:error:function(xhr,status,error){}
})
})
</script>点击 "运行实例" 按钮查看在线实例
<?php
//print_r($_GET[name]);exit;
//用数组来模拟数据库已经存在的用户名
$nameList = ['admin','hi','php'];
//给当前用户提交的用户名
$userName = $_GET['name'];
//判断用户名是否为空
if (strlen(trim)($userName)) ==0 {
echo '<span style="color:red">用户名不能为空</span>';
//判断是否为纯数字
}elseif (is_numeric($userName)) ==0 {
echo '<span style="color:red">用户名不能为纯数字</span>';
//判断是否重复
}elseif (is_array($userName)) ==0 {
echo '<span style="color:red">用户名不能重复</span>';
//用户名可用提示
}else{
echo '<span style="color:blue">恭喜,注册成功</span>';
}

运行实例 »点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号