怎样用php做登陆页面 并且连接数据库

第1个回答  2016-06-07
人潮梦太多 你就不要想起我
第2个回答  推荐于2017-11-22
<html>
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style>
#registForm{
width: 500px;
height: 140px;
border: 1px solid #666;
margin: auto;
margin-top: 30px;
padding-left: 20px;
border-radius: 5px;
box-shadow: 10px 5px 5px #eee;

}
.lab1{
text-shadow: 2px 1px 1px #555;
}
input[type=text]{
margin-left: 10px;
border: 1px dotted #a7c942;
border-radius: 5px;
box-shadow: 2px 3px 4px #666;
color: #666;
font-size: 14px;
font-weight: bold;
text-indent: 8px;
width:200px;
}
input[type=password]{
margin-left: 10px;
margin-left: 10px;
border: 1px dotted#a7c942;
border-radius: 5px;
box-shadow: 2px 3px 4px #666;
width:200px;
}
input[name=btn_submit]{
margin-left: 60px;
}
input[name=btn_reset]{
margin-left: 20px;
}
.btn{
background-color: green;
color: #fff;
border: 1px solid red;
border-radius: 5px;
}
.tip1, .tip2{
color: red;
}
</style>
</head>
<body>
<?php
// put your code here
?>
<form method="post" id="registForm"action="">
<p>
<labelfor="userName">用户名</label>
<input type="text"name="userName" id="userName">
<spanclass="tip1">*</span>
</p>
<p>
<labelfor="userPass">密 码</label>
<inputtype="password" name="userPass" id="userPass">
<spanclass="tip2">*</span>
</p>
<p>
<inputtype="submit" name="btn_submit" value="登录"class="btn">
<inputtype="reset" name="btn_reset" value="注销"class="btn">

</p>
</form>

</body>
<script src="jquery.js"></script>
<script>
$(function () {
$("#userName").blur(function () {
// alert("haha");
var len =$("#userName").val().length;
//alert(len);
if (len < 5) {
$(".tip1").html("必填,且长度不少于5位。");
$(".tip1").css("color", "red");
} else
{
$(".tip1").html("√");
$(".tip1").css("color", "green");
}
});
$("#userPass").blur(function () {
// alert("haha");
var len = $("#userPass").val().length;
//alert(len);
if (len < 5) {
$(".tip2").html("不能为空,长度不低于3位。");
$(".tip2").css("color", "red");
} else
{
$(".tip2").html("√");
$(".tip2").css("color", "green");
}
});
});
</script>
</html>追问

可以连接数据库吗 希望具体一点

追答

连接数据库文件 conn.php
//创建连接
$conn = new mysqli("localhost", "root","", "db_student");
//检测连接
if ($conn->connect_error) {
die("Link error:" . $conn->connect_error);
}
//设置编码
$conn->set_charset("utf8");

追问

求大神优化下登录页面 最好把信息显示页面写下 大恩不言谢

追答

优化页面,实现登陆转向
query($query);
if ($result->num_rows > 0) {
header("Location:view_info.php");
}
?>

本回答被提问者和网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网