![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2006
Posts: 13
Rep Power: 0
![]() |
Use cookie in form
Hi there.
I'm working on a Python program where I load a form with text fields and then save input as a cookie. I print my HTML code by doing: print content-type: text/html
print '''
<html><head><title>......
<form>
<input name="replace" type="text" size="25" value=""/>
</form>.....'''
if os.environ.has_key('HTTP_COOKIE'):
cookie.load(os.environ['HTTP_COOKIE'])
if cookie.has_key('url') and cookie.has_key('find') and cookie.has_key('replace'):
print cookie['mycookie']
print '</body></html>'I have two questions. One is that my cookies are not replaced by the newest search words. I just have the first cookie from the first search I did with my script. Second question and hurtle is, that I want my value="" in my form to have the last word I've entered in my text field, that is my cookie for "mycookie". I can post the whole code if it's easier for you to see my problem and/or explain what I'm doing wrong. Greetings Public2 |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Aug 2006
Posts: 13
Rep Power: 0
![]() |
Have found a solution...
|
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Aug 2006
Posts: 13
Rep Power: 0
![]() |
The solution was:
Question 1: To make a cookie from my input forms, I had to set it up like this: cookie = Cookie.SimpleCookie()
if form.has_key('form1') and form.has_key('form2') and form.has_key('form3'):
cookie['form1'] = form['form1'].value
cookie['form1']['expires']=25920000
cookie['form2'] = form['form2'].value
cookie['form2']['expires']=25920000
cookie['form3'] = form['form3'].value
cookie['form3']['expires']=25920000
print cookieThen i use my cookies as arguments when I call my HTMLbody function: HTMLbody(cookie['form1'].value,cookie['form2'].value,cookie['form3'].value) I my HTML body, I write my HTML out, and use my cookies with the %-function, like this: <div> <label for="t1">FORM1:</label><input type="text" name="form1" id="t1" value="%s"/><br /> <label for="t2">FORM2:</label><input type="text" name="form2" id="t2" value="%s"/><br /> <label for="t3">FORM3:</label><input type="text" name="form3" id="t3" value="%s"/><br /> </div> <div> <label for="t1">FORM1:</label><input type="text" name="form1" id="t1" value="%s"/><br /> <label for="t2">FORM2:</label><input type="text" name="form2" id="t2" value="%s"/><br /> <label for="t3">FORM3:</label><input type="text" name="form3" id="t3" value="%s"/><br /> </div> </fieldset> <div><input type="submit" value="SEARCH" id="submit" /></div> </form> </center> </body></html>''' %(form1cookie,form2cookie,form3cookie) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Show or hiding forms/modifying control properties ..from different a form.. | cloud- | C# | 4 | Nov 10th, 2006 10:51 AM |
| Visual Basic 6.0 Form Effects | fox123 | Visual Basic | 7 | Dec 21st, 2005 7:03 AM |
| Form Submit Blues | MegaArcon | Python | 3 | Dec 14th, 2005 4:20 PM |
| .NET Timer Form closing issue | MBirchmeier | C# | 4 | Nov 21st, 2005 10:00 AM |
| entering data into excel from a form | glevine | Perl | 1 | Nov 18th, 2005 5:03 PM |