title: Python Email validation on the same page
body: <p>I'm trying to make a simple email validation application. It only has to pages the index and the success  page that list all of the emails. There are three routes a index route, validation route and finally the success route that list the actual emails. here is my code:</p>
  
  <pre><code>from flask import Flask, request, redirect, render_template, session
  import datetime
  from mysqlconnection import MySQLConnector
  
  app = Flask(__name__)
  mysql = MySQLConnector(app,'friendsdb')
  
  @app.route('/', methods=['POST','GET'])
  def index():
      if request.method=='GET':
          return render_template('index.html')
      elif request.method=='POST':
          friends = mysql.query_db("SELECT * FROM friends")
          print friends
          print request.form['first_name'],
          print request.form['last_name'],
          print request.form['Age']
          return render_template('index.html')
  
  #@app.route('/delete/&lt;friend_id&gt;', methods=['POST'])
  #def delete(friend_id):
      #query = "DELETE FROM friends WHERE id = :id"
      #data = {'id': friend_id}
      #mysql.query_db(query, data)
      #return redirect('/')
  
  app.run(debug=True)
  </code></pre>
  
  <p>and my html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
    &lt;h1&gt;Friends&lt;/h1&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="/" methods="GET"&gt;
      &lt;table&gt;
        &lt;th&gt;Name:&lt;/th&gt;
        &lt;th&gt;Age:&lt;/th&gt;
        &lt;th&gt;Friend Since:&lt;/th&gt;
        {% for friends in all_friends: %}
        &lt;tr&gt;ID:{{friends['id']}}&lt;/tr&gt;
        &lt;tr&gt;First Name:{{friends['first_name']}}Last Name:{{friends['last_name']}}&lt;/tr&gt;
        &lt;tr&gt;Age:{{friends['age']}}&lt;/tr&gt;
        &lt;tr&gt;Date:{{friends['NOW();']}}&lt;/tr&gt;
        &lt;tr&gt;&lt;form action="/delete" method="POST"&gt;
          &lt;p&gt;Delete a friend&lt;/p&gt; &lt;input type="submit"&gt;&lt;/tr&gt;
        {%endfor%}
    &lt;/form&gt;
      &lt;/table&gt;
  
      &lt;h1&gt;Add a Friend&lt;/h1&gt;
    &lt;form action="/" method="POST"&gt;
     &lt;p&gt;First Name:&lt;/p&gt;&lt;input type="text" name="first_name"&gt;
     &lt;p&gt;Last Name:&lt;/p&gt;&lt;input type="text" name="last_name"&gt;
     &lt;p&gt;Age&lt;/p&gt;&lt;input type="text" name="age"&gt;
     &lt;input type="submit"&gt;
    &lt;/form&gt;
  
  
    &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>im trying to input the data from the inputs to the table on top any suggestions?</p>