如何访问在html表单条目中输入的数据

时间:2019-07-23 13:10:12

标签: cgi python-3.6

我有一个signup.py文件,其中我编写了python脚本来访问该网页,但是每当我在网页上的注册详细信息中输入任何详细信息时,该脚本都无法正常工作。

#!/usr/bin/pythn3

import cgi, cgitb , mysql.connector
cgitb.enable()
print("Content-type:text/html")
print("")
mydb=mysql.connector.connect("root","root123","login","localhost")
mycursor=mydb.cursor()

# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from fields
first_name = form.getvalue('email')
passwd  = form.getvalue('psw')

sql="INSERT INTO log_table (email_, pass_) VALUES (%s, %s)"
val=(first_name, passwd)
mycursor.execute(sql,val)
mydb.commit()

我想将html表单的值推入数据库

0 个答案:

没有答案
相关问题