Advertisement
Guest User

Untitled

a guest
Oct 9th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. app = Flask(__name__)
  2.  
  3. # Connect to the database
  4. connection = pymysql.connect(host='localhost',
  5. user='root',
  6. password='1234',
  7. db='mydb',
  8. charset='utf8mb4',
  9. cursorclass=pymysql.cursors.DictCursor)
  10. @app.route('/')
  11. def index():
  12. return render_template('signup.html')
  13. @app.route('/signup', methods=['POST', 'GET' ])
  14. def signup():
  15. cursor = connection.cursor()
  16. if request.method == 'POST':
  17. try:
  18. cursor.execute('''INSERT INTO users (user, fname, lname, email, pnum, password) VALUES (%s, %s, %s, %s, %s, %s)''')
  19. cursor.commit()
  20. finally:
  21. return render_template('login.html')
  22.  
  23.  
  24. if __name__ == '__main__':
  25. app.run(debug=True)
  26.  
  27. <h1>Please Sign Up</h1>
  28.  
  29. <button onclick="document.getElementById('id01').style.display='block'"style="width:auto;">Sign Up</button>
  30.  
  31. <div id="id01" class="modal">
  32. <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
  33. <form class="modal-content animate" action="/signup" method="POST">
  34. <div class="container">
  35. <label><b>Email</b></label>
  36. <input type="text" placeholder="Enter Email" name="email" required>
  37.  
  38. <label><b>Password</b></label>
  39. <input type="password" placeholder="Enter Password" name="password" required>
  40.  
  41. <label><b>user</b></label>
  42. <input type="text" placeholder="user" name="user" required>
  43.  
  44. <label><b>First name</b></label>
  45. <input type="text" placeholder="First name" name="fname" required>
  46.  
  47.  
  48. <label><b>pnum</b></label>
  49. <input type="text" placeholder="Pnum" name="pnum" required>
  50.  
  51. <label><b>Last name</b></label>
  52. <input type="text" placeholder="Last name" name="lname" required>
  53. <input type="checkbox" checked="checked"> Remember me
  54. <p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
  55.  
  56. <div class="clearfix">
  57. <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
  58. <button type="submit" action="/Signup" method="POST" class="signupbtn">Sign Up</button>
  59. </div>
  60. </div>
  61.  
  62. <script>
  63. // Get the modal
  64. var modal = document.getElementById('id01');
  65.  
  66. // When the user clicks anywhere outside of the modal, close it
  67. window.onclick = function(event) {
  68. if (event.target == modal) {
  69. modal.style.display = "none";
  70. }
  71. }
  72. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement