标签:分享 text ++ get sql ext head box ping
js:设置return
function fnLogin() {
var un = document.getElementById("username");
var us = document.getElementById("password");
var uE = document.getElementById("error_box")
var isE = true;
uE.innerHTML = "<br>";
if (un.value.length < 6 || un.value.length > 20) {
document.getElementById(‘error_box‘).innerHTML = "用户名必须在6-20个字符之间";
isE = false;
return isE;
} else if ((un.value.charCodeAt(0) >= 48) && (un.value.charCodeAt(0) <= 57)) {
uE.innerHTML = "用户名首字母不能为数字";
isE = false;
return isE;
}
else for (var i = 0; i < un.value.length; i++) {
if (((un.value.charCodeAt(i) < 48) || (un.value.charCodeAt(i) > 57)) && ((un.value.charCodeAt(i) < 97) || (un.value.charCodeAt(i) > 122))) {
uE.innerHTML = "用户名只能为数字或字母";
isE = false;
return isE;
}
}
if (us.value.length < 6 || us.value.length > 20) {
document.getElementById(‘error_box‘).innerHTML = "密码必须在6-20个字符之间";
isE = false;
return isE;
}
return isE;
}
html:设置
<!DOCTYPE html>
<html lang="en">
<head>
{% extends ‘index.html‘ %}
<meta charset="UTF-8">
<title>
{% block title %}
登录页
{% endblock %}</title>
{% block head %}
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="{{ url_for(‘static‘,filename=‘javascript/dl.js‘) }}"></script>
<link rel="stylesheet" type="text/css" href="{{ url_for(‘static‘,filename=‘css/dl.css‘) }}">
{% endblock %}
</head>
<body>
{% block body %}
<form action="{{ url_for(‘login‘) }}" method="post">
<div id="dljm" class="panel panel-info">
<h2 class="deng" class="panel-title">登陆</h2>
<div id="nr" class="panel-body">
<div class="input_box">
Username:<input type="text" id="username" placeholder="请输入用户名" name="dlusername">
</div>
<br>
<div class="input_box">
Password: <input type="password" id="password" placeholder="请输入密码" name="dlpassword">
</div>
<div class="error_box" id="error_box"><br></div>
<div class="bt">
<button class="zhuce" onclick="fnLogin()">登录</button>
</div>
<br>
<input type="radio" name="role" value="stu">学生
<input type="radio" name="role" value="tea">教师<br>
<input type="checkbox" value="true"><span>记住我</span><br><a
href="http://www.gzcc.cn/html/yonghufenglei/xuesheng/">登陆遇到问题</a><br>
</div>
</div>
</form>
{% endblock %}
</body>
</html>
py:
@app.route(‘/register/‘, methods=[‘GET‘, ‘POST‘])
def register():
if request.method == ‘GET‘:
return render_template(‘zhuce.html‘)
else:
username = request.form.get(‘username‘)
password = request.form.get(‘password‘)
nickname = request.form.get(‘nickname‘)
userphone=request.form.get(‘userphone‘)
user = User.query.filter(User.username == username).first()
if user:
return "账户已存在"
else:
user = User(username=username, password=password, nickname=nickname,userphone=userphone)
db.session.add(user)
db.session.commit()
return redirect(url_for(‘login‘))
session:
import os
DEBUG=True
SECRET_KEY=os.urandom(24) #加密key
DIALECT=‘myaql‘
DRIVER=‘mysqldb‘
USERNAME=‘root‘
PASSWORD=‘ROOT‘
HOST=‘127.0.0.1‘
PORT=‘3306‘
DATABASE=‘mis_db‘
标签:分享 text ++ get sql ext head box ping
原文地址:http://www.cnblogs.com/z1-z/p/7881446.html