这里是我的form.html得到错误
form name="form1" action="/cgi-bin/form2.py" method="post"
input type="text" name="firstname"
input type="submit" value="submit"
以下是我的form2.py
import cgi
print 'Content-type:text/html\n\n'
cookie=Cookie.SimpleCookie()
form = cgi.FieldStorage()
searchterm = form["firstname"].value
print 'Set-Cookie: lastvisit=' + str(searchterm)
cookie["firstname"]=searchterm
print "firstname="+ cookie["firstname"].value
cookie_string = os.environ.get('HTTP_COOKIE')
if not cookie_string:
print '<p>First visit or cookies disabled</p>'
else:
print '<p>The returned cookie string was "' + cookie_string + '"</p>'
cookie.load(cookie_string)
lastvisit = float(cookie['lastvisit'].value)
cookie['lastvisit']['path'] = '/var/www/cgi-bin/'
print searchterm
print 'Content-type:text/html\n\n'
print "<meta http-equiv='refresh' content='5'>"
我们有一个form.html和form2.py文件,从form.html我提交名字form2.py提交后,我得到'searchterm'值,然后我刷新刷新我得到<type 'exceptions.keyerror'>:firstname
后的浏览器。 即使我已设置和检索cookie值,我无法使用cookie值刷新浏览器。 请帮我,我过去4天面临这个问题。
谢谢, Vittal。
嗯,这将HTML似乎事实引用一个名为'sa2.py'的脚本,而你说你的代码是'form2.py'可能值得一看。 – Aya 2013-04-25 11:44:18
对不起,输入错误,其action =“/ cgi-bin/form2.py”只有 – 2013-04-25 12:20:43