我愿意填写表单(HTML)并将该数据传递到另一个 HTML 页面,并将该数据插入数据库。
应用程序.py
@app.route('/signup')
def signup():
return render_template("client_signup.html")
@app.route('/registered')
def registered():
userName = request.form['userName']
userEmail = request.form['userEmail']
userPassword = request.form['userPassword']
conn = mysql.connect()
cursor = conn.cursor()
cursor.execute("INSERT INTO emp(userName, userEmail, userPassword) VALUES (%s,%s,%s)", (userName, userEmail, userPassword))
return render_template("client_signin.html")
client_signup.html
<form id="msform" action="registered">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Account Setup</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="userName" placeholder="Your Name" />
<input type="text" name="UserEmail" placeholder="Email" />
<input type="password" name="userPassword" placeholder="Password" />
<input type="password" name="cUserPassword" placeholder="Confirm Password" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>
我不必了解 FLASK(只是初学者)