Before be able to make what you want do which is to "Compare 2 HTML Forms" you should do the following:
Make sure that you want to run the comparison (or display any other thing really) After the user clicked the submit button. Because if is before then this can be done with JavaScript only, but if is after the submit button then go to step 2.
You need to 'save' the state of the form From Flask's server back to the browser (Server Side ---> Client Side). I prepare a simple App in order to show you this:
1. Add this to app.py
from flask import Flask,request, render_template
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
print('here')
email_1 = request.form['email']
email_2 = request.form['email_conf']
return render_template('index.html', email_1=email_1, email_2=email_2)
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
2. Add this to template/index.html
NOTE: You had the closing tag in the input, is not needed as input are auto closing tags
<form action="/" method="POST">
<input type="email" name="email">
<input type="email" name="email_conf">
<input type="submit" value = "Entrar">
</form>
<!-- Show the Output -->
{{email_1}} {{email_2}}
<!-- Do wathever you want with that -->
{% if email_1 and email_2 %}
{% if email_1 == email_2 %}
<p>My email is {{email_1}} and I put the same as {{email_2}}</p>
{% elif email_1 == 'eggs@spam.com'%}
<p>{{email_1}} likes Python</p>
{% for word in email_1 %}
<option >{{word}}</option>
{% endfor%}
{% else %}
<p>Something wrong with {{email_1}} maybe not match this-> {{email_2}}??</p>
{% endif %}
{% endif %}
Documentation
{{email}}
{% endif %}` however even when the emails are the same nothing is showed on the screen. – leoperassoli Jan 03 '21 at 10:29