日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql 凭证_如何用mysql验证flask/python中的凭证?

發(fā)布時(shí)間:2023/12/15 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 凭证_如何用mysql验证flask/python中的凭证? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Flask/python登錄驗(yàn)證對(duì)mysql不起作用,我在搜索google和文檔,我在同一件事上看到了一些關(guān)于堆棧溢出的問(wèn)題,但還沒(méi)有得到回答。在from flask import Flask, render_template, flash, request, url_for, redirect, session

from content_management import Content

#form validations

from wtforms import Form, BooleanField, TextField, PasswordField, validators

#to encrypt the password

from passlib.hash import sha256_crypt

#for SQL injection

from MySQLdb import escape_string as thwart

import gc

from functools import wraps

from mysql_connect import connection

app = Flask(__name__)

@app.route('/login/', methods=['GET','POST'])

def login_page():

error = ''

try:

c, conn = connection()

if request.method == "POST":

d = c.execute("SELECT * FROM clients WHERE email = (%s)", (thwart(request.form['email']),))

d = c.fetchone()[2]

if request.form['password'] == d:

email = request.form['email']

c.execute("SELECT * FROM clients WHERE email = (%s)", (thwart(email),))

clients_table = c.fetchall()

clientcid = clients_table[0]

flash(clientcid)

phone = clients_table[1]

rating = clients_table[4]

conn.commit()

c.execute("SELECT * FROM cpersonals WHERE cid = (%s)", (clientcid,))

cpersonals_table = c.fetchall()

first_name = cpersonals_table[1]

last_name = cpersonals_table[2]

address = cpersonals_table[3]

czip = cpersonals_table[4]

reg_date = cpersonals_table[5]

conn.commit()

c.close()

conn.close()

session['logged_in'] = 'client'

session['clientcid'] = clientcid

session['email'] = email

session['phone'] = phone

session['rating'] = rating

session['first_name'] = first_name

session['last_name'] = last_name

session['address'] = address

session['czip'] = czip

session['reg_date'] = reg_date

flash("You are now logged in.")

return redirect(url_for("dashborad"))

else:

error = "Invalid credentials, try again."

return render_template("login.html")

在沒(méi)有框架的情況下,有沒(méi)有一種簡(jiǎn)單的方法可以在MySQL中驗(yàn)證憑證

總結(jié)

以上是生活随笔為你收集整理的mysql 凭证_如何用mysql验证flask/python中的凭证?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。