Problem filling an html form

Νικόλαος Κούρας nikos.kouras at gmail.com
Fri Jan 13 12:02:17 EST 2012


# get some enviromental values
form = cgi.FieldStorage()
mail = form.getvalue('mail') or ''
comment = form.getvalue('comment') or ''

	# insert guest comments into database if form was submitted
	if '@' in mail and comment not in ("Ρωτήστε με σχετικά..."):
		try:
			cursor.execute( '''INSERT INTO users(mail, comment) VALUES(%s,
%s)''', (mail, comment) )
		except MySQLdb.Error, e:
			print ( "Error %d: %s" % (e.args[0], e.args[1]) )

		print ( "<h2><font color=blue>Ευχαριστώ για την ερώτηση! Θα σας
απαντήσω το συντομότερο δυνατό!" )
		sys.exit(0)
	else:
		print ( "<h2><font color=red>Συμπλήρωσε σωστά το mail σου και δώσε
το σχολιασμό σου!" )
		sys.exit(0)
==============================================

In my webpage here http://superhost.gr/hosting.html i ask the users
mail and comment in a html form.

No matter what info the user gives after he submits the form, nothing
else happens instead of reloading the page itself while what i want
the code to do is to enter the if structure and display the
appropriate message, depending if the user entered data in the imput
box or not.

Am i missing something here?



More information about the Python-list mailing list