redirecting to a content page

S

Shreyas

I am a new user writing some scripts to store data entered via a
browser into a database. I have several content pages, and one
"processing" page. A content page often has a form like this:

<form method=POST action=processing.py>
<input type=text name=username>
....

And the processing page goes like this:

form = cgi.FieldStorage()
## do some work, put data into the db

The thing is, processing.py doesn't have any content that I want to
display to the user. I would ideally like processing.py to seamlessly
send the user back to the content page that it came from, perhaps with
some parameter tweaks.

Instead, I am having to write intermediate steps like this into
processing.py:

Return to the <a href=contentPage.py?submit=true>page</a> you came
from.

Please let me know if there's a way to do this, or if my general
approach (having such a processing page) is off.

Thanks,

Shreyas

- I did try searching for this in the archive but am not even entirely
sure what it is called...
 
B

bruno at modulix

Shreyas said:
I am a new user writing some scripts to store data entered via a
browser into a database. I have several content pages, and one
"processing" page. A content page often has a form like this:

<form method=POST action=processing.py>
<input type=text name=username>
...

And the processing page goes like this:

form = cgi.FieldStorage()
## do some work, put data into the db

The thing is, processing.py doesn't have any content that I want to
display to the user.

And this is a GoodThing(tm). A successful post should always be followed
by a redirect.
I would ideally like processing.py to seamlessly
send the user back to the content page that it came from, perhaps with
some parameter tweaks.

import cgi

print "Location: %s\n\n" % url_of_the_page_you_want_to_redirect_to

(snip)
Please let me know if there's a way to do this, or if my general
approach (having such a processing page) is off.

Nope, having a separate script doing the form processing, then
redirecting is the right thing to do.
- I did try searching for this in the archive but am not even entirely
sure what it is called...

It's a redirection. If you are to work with CGI (or any other web
programming solution FWIW), you'd better know the HTTP protocol.
 
S

Shreyas

Thanks much, Location: took care of what I needed. I'll look to the
http protocols for the future.

Shreyas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top