Fixed SQL queries and HTML forms