Advertisement
Guest User

Formulario en psp

a guest
Nov 19th, 2010
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. <%
  2. #Definimos una funcion para mostrar el formulario
  3. def formulario():
  4. %>
  5. <p>Envianos tus datos</p>
  6. <form method="post" action="formulario.psp">
  7.     Nombre:<input type="text" id="nombre" name="nombre" />
  8.     Apellidos:<input type="text" id="apellidos" name="apellidos" />
  9.     <input type="submit" value="enviar" />
  10. </form>
  11. <%
  12. #end formulario
  13. %>
  14. <html>
  15. <body>
  16. <%
  17. #Comprobamos que nos llegan parametros de un formulario que esperamos
  18. if form.has_key('nombre') and form.has_key('apellidos'):
  19.     #Comprobamos que estos parametros no llegan vacios
  20.     if req.form['nombre'] != '' and req.form['apellidos'] !='':
  21.         nombre = req.form['nombre']
  22.         apellidos = req.form['apellidos']
  23. %>
  24. <h4>Hola <%=nombre +' '+ apellidos+'!!' %><h4>
  25. <%
  26.     else:
  27.         #Si los datos estan vacios mostramos el formulario
  28.         formulario()
  29. else:
  30.     #Si no existen datos del formulario mostramos el formulario
  31.     formulario()
  32. #end if
  33. %>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement