I get an error:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "C:\Documents and Settings\EKIXHOO\Desktop\Dados\Motor.py", line 10, in ?
nombre = formulario['nombre'].value
File "C:\Python22\lib\cgi.py", line 550, in __getitem__
raise KeyError, key
KeyError: nombre
And here is the little script:
#!/usr/bin/python2
import cgitb; cgitb.enable()
import string, random, smtplib, cgi
print 'Content-type: text/html'
print
formulario = cgi.FieldStorage()
nombre = formulario['nombre'].value
correo = formulario['correo'].value
dado = formulario['dado'].value
valores = dado.split('d')
numero = int(valores[0])
caras = int(valores[1])
if numero <= 20 and numero >= 1 and caras <= 100 and caras > 1:
random.seed()
tiradas = []
for i in range(numero):
tiradas.append(random.randint(1,caras))
secuencia = str(tiradas)
secuencia = secuencia.strip('[')
secuencia = secuencia.strip(']')
mensaje = nombre + '(' + dado + '): ' + secuencia
servidor = smtplib.SMTP('localhost')
servidor.set_debuglevel(1)
servidor.sendmail('gaz082@yahoo.com.ar', correo, mensaje)
servidor.quit()
print '<h3>Tirada enviada a ' + correo + '.</h3>'
print 'No digo que sacaste para agregar misterio...'
print 'Gracias por usarme!.'
else:
print 'Error, error, ahh, ahh!, error! Mantengamos la calma...'
print '0 < Dados <= 20 y 1 < Caras <= 100 ?'
print 'Pulsa retroceder, verifica esas condiciones e intenta de nuevo.'
Ive got the form in another html file with the action="file.py or .cgi" stuff, post mode.
Thanks for any help that you could give me.