很多人觉得入门很难,看了太多的基础,还是不会,学了半年还是茫然。有问题不知道如何解决。
其实入门只要找到学习方法,以及学习哪些基础,学习路线,入门是很轻松、很快乐的事。
php学习群,希望大家多交流277304970
这节课,用到的知识点:
1、form表单
2、button
3、input编辑框
4、php的接受post数据
5、mysqli
6、js的弹出框
先看效果,
登录框:
代码:
1、登录form表单,
-
<form method="post", action="index.php">
-
<fieldset>
-
<label class="block clearfix">
-
<span class="block input-icon input-icon-right">
-
<input type="text" name="username" class="form-control" placeholder="Username" />
-
<i class="ace-icon fa fa-user"></i>
-
</span>
-
</label>
-
-
<label class="block clearfix">
-
<span class="block input-icon input-icon-right">
-
<input type="password" name="password" class="form-control" placeholder="Password" />
-
<i class="ace-icon fa fa-lock"></i>
-
</span>
-
</label>
-
-
<div class="space"></div>
-
-
<div class="clearfix">
-
<label class="inline">
-
<input type="checkbox" class="ace" />
-
<span class="lbl"> Remember Me</span>
-
</label>
-
-
<button type="submit" class="width-35 pull-right btn btn-sm btn-primary">
-
<i class="ace-icon fa fa-key"></i>
-
<span class="bigger-110">登录</span>
-
</button>
-
</div>
-
-
<div class="space-4"></div>
-
</fieldset>
-
</form>
登录php处理:
-
include_once("mysqli.php");
-
-
$user= $_POST['username'];
-
$pwd=$_POST['password'];
-
-
-
$sql = "select * from admin where username='".$user."'";
-
-
-
$query1 = $mysqli->query($sql);
-
-
-
if($query1==null){
-
-
-
echo '
';
-
echo '
alert("用户名不存在");
';
-
echo '
window.location.href="login.html"
';
-
return;
-
}
-
-
if($query1->num_rows==null){
-
-
-
echo '
';
-
echo '
alert("用户名不存在1");
';
-
echo '
window.location.href="login.html"
';
-
return;
-
}
-
-
$result=$query1->fetch_array();
-
-
if($result['password'] != $pwd){
-
-
-
echo '
';
-
echo '
alert("密码错误");
';
-
echo '
window.location.href="login.html"
';
-
return;
-
}
-
$result->free();//释放查询内存(销毁)
$mysqli->close();//别忘了关闭你的"小资源";
阅读(1853) | 评论(0) | 转发(0) |