Hakunin

FPR_V5

Apr 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.33 KB | None | 0 0
  1. #! C:\Python\python.exe
  2.  
  3. import cgi,cgitb
  4. import re
  5. cgitb.enable();
  6. form = cgi.FieldStorage()
  7.  
  8. ime = form.getvalue('ime')
  9. prezime = form.getvalue('prezime')
  10. adresa = form.getvalue('adresa')
  11.  
  12. brojTel = form.getvalue('brojTel')
  13. brojTel = re.sub(r'\D',"",brojTel)
  14. if brojTel == "":
  15.     brojTel="GRESKA_TELEFON"
  16.  
  17. email = form.getvalue('email')
  18. vrsta = form.getvalue('vrsta')
  19. velicina =  form.getvalue('velicina')
  20.  
  21.  
  22.  
  23. print ("Content-type:text/html\r\n\r\n")
  24. print ('<html>' )
  25. print ('<head>' )
  26. print ('<title>Hello Word - CGI Program</title>' )
  27. print ('</head>' )
  28. print ('<body>' )
  29. print ('<h2>Hello Word! This is CGI program</h2>' )
  30. print(ime,prezime,adresa,brojTel,email,vrsta,velicina)
  31. if form.getvalue('kecap'):
  32.     print("kecap")
  33. if form.getvalue('korica'):
  34.     print("korica")
  35. if form.getvalue("bla"):
  36.     print("bla")
  37.  
  38. file = open('C:\\xampp\\cgi-bin\\v5\\narudzbina.txt', "w+")
  39. stringovi = ime + " " + prezime + " " + adresa + " " + brojTel\
  40.             +" " + email + " " + vrsta + " "+ velicina+ " "
  41. file.write(stringovi)
  42. if form.getvalue('kecap'):
  43.     file.write("kecap ")
  44. if form.getvalue('korica'):
  45.     file.write("korica ")
  46. if form.getvalue("bla"):
  47.     file.write("bla ")
  48.  
  49.  
  50. print ('</body>' )
  51. print ('</html>' )
  52.  
  53. ///////////////////
  54.  
  55. <!DOCTYPE html>
  56. <html lang="en">
  57. <head>
  58.     <meta charset="UTF-8">
  59.     <title></title>
  60. </head>
  61. <body>
  62. <form action="http://localhost/cgi-bin/v5/app.py" method="get">
  63.     <p>Ime <input type="text" name="ime"></p>
  64.     <p>Prezime <input type="text" name="prezime"></p>
  65.     <p>Adresa <input type="text" name="adresa"></p>
  66.     <p>Broj telefona <input type="text" name="brojTel"></p>
  67.     <p>e-mail <input type="text" name="email"></p>
  68.     <p>Vrsta pice
  69.         <select name="vrsta" id="">
  70.             <option value="capricoza">capricoza</option>
  71.             <option value="feferoni">feferoni</option>
  72.         </select>
  73.     </p>
  74.     <p>Velicina
  75.         <input type="radio" name="velicina" value="24">24
  76.         <input type="radio" name="velicina" value="32">32
  77.         <input type="radio" name="velicina" value="40">40
  78.     </p>
  79.     <p>Dodaci:
  80.         kecap<input type="checkbox" name="kecap">
  81.         korica<input type="checkbox" name="korica">
  82.         bla<input type="checkbox" name="bla">
  83.     </p>
  84.     <input type="submit" value="Poruci">
  85. </form>
  86.  
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment