0 Replies - 488 Views - Last Post: 23 June 2014 - 11:36 PM Rate Topic: -----

#1 Hrand   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 109
  • Joined: 25-June 12

CGI Help

Posted 23 June 2014 - 11:36 PM

Here is the code
#!/usr/bin/python
import cgi
import cgitb 
form = cgi.FieldStorage()
username = form.getvalue('name')

print 'Content-type:text/html\r\n\r\n'
print '<html>'
print '<head>'
print '<title>Text Adventure</title>'
print '</head>'
print '<body>'
print """
<form action="/game.py" method="post">
Enter Your Name: <input type="text" name="name"><br />
<input type="submit" value="Submit" />
</form>"""

print('Hello ' + username + ' pick a weapon from this list to start your fucking awesome adventure [sword, bat, bow]')
if username != '':
	weapon = form.getvalue('weapon')
	print """
	<form action="/game.py" method="post">
	Enter Weapon: <input type="text" name="weapon"><br />
	<input type="submit" value="Submit" />
	</form>"""


print '</body>'
print '</html>'





My problem is that I would like to be able to replace the first form input with the second one. Right now both forms appear on the page after you hit the first submit button.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1