473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to handle two forms in cgi?

lli
Hi Guys,

I am a new cgi programmer. Now I need to design a web application:
1. first, user login by their username and password in a form (login
form). When users click submit button it connect to database and check
user name and password in a table. If it match in a table, form1.py
should show second form for users in their browser. I have finish this
form. It works well.
2. second form (search form) which contain last name, and first name
which users input data. When user click submit button, it connect
database and search in a table. And the search result need to show in a
list or table in users' browser.

My question is: How let these two form works together? I try to use
two codes for these two forms, e.g. Login.py for login form and
search.py for search form. But when user input data in search form and
click its submit button, it just comes back to login form. Second form
doesn't work.

Any help is appriciated!

Thanks,

LLI

Nov 30 '05 #1
9 2036
> My question is: How let these two form works together? I try to use
two codes for these two forms, e.g. Login.py for login form and
search.py for search form. But when user input data in search form and
click its submit button, it just comes back to login form. Second form
doesn't work.

Any help is appriciated!


It sounds like the "action" attribute in the 2nd form's <form> tag is not
pointing to search.py.

Nov 30 '05 #2
lli
Hi Dan,

Sure. You are right. When I correct this according to your idea, it
works now. Thank you very much. But I have second problem. When users
run second form, other people can see adress in users' browers and know
how to run the second form, so they don't need to run login form. How I
can handle this case? How I can let users run login form firstly, then
they can run second form(search form)?

By the way I use python to write cgi.

Any help is appriciated!

Dec 2 '05 #3
ll*@sos.state.tx.us wrote:
Hi Dan,

Sure. You are right. When I correct this according to your idea, it
works now. Thank you very much. But I have second problem. When users
run second form, other people can see adress in users' browers and know
how to run the second form, so they don't need to run login form. How I
can handle this case? How I can let users run login form firstly, then
they can run second form(search form)?

By the way I use python to write cgi.

Any help is appriciated!

I'm afraid you are running into what are called "session state"
problems. In other words, your system needs to be able to "remember"
that a user has already successfully visited one page before allowing
them to visit another.

There are various ways to solve this problem, but most of them revolve
around maintaining state information for each different concurrent user
of your web. Once a user successfully logs in your record "logged in =
True" or similar in your session state memory, and at the start of each
CGI script for which the user is required to be logged in you actually
check the state memory to verify that is the case.

There are various mechanisms for maintaining session state, many of
which rely on serving a cookie to each user's browser. This allows your
server to identify which session any particular request is a part of.

See if

http://starship.python.net/crew/dave...i?req=all#2.11

makes any sense to you. If not, you might want to Google around a bit
for things like "Python web session" to see what you can find.

Note there are plenty of web frameworks (e.g. CherryPy, mod_python) that
offer assistance with maintaining session state, but it isn't impossible
to maintain it yourself in CGI scripts once you understand the problem.
Good luck!

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 4 '05 #4
lli
Hi Steve,

Thank you for your information. Your idea is helpful for me.
By the way, could I use "hiden" to handle this case?

Laya

Dec 5 '05 #5

ll*@sos.state.tx.us wrote:
Hi Dan,

Sure. You are right. When I correct this according to your idea, it
works now. Thank you very much. But I have second problem. When users
run second form, other people can see adress in users' browers and know
how to run the second form, so they don't need to run login form. How I
can handle this case? How I can let users run login form firstly, then
they can run second form(search form)?

By the way I use python to write cgi.

You can use logintools to add a user authentication framework to any
CGI with very little work.

This lets you control who is able to login (whether or not new users
can sign up and you have an interface to create/invite new users).

It will also prevent any script being run unless the user is logged in.
It uses cookeis for authentication and can be added to a standard CGI
with as little as two lines of code.

It is designed for exactly the problem you have.

http://www.voidspace.org.uk/python/logintools.html

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml Any help is appriciated!


Dec 5 '05 #6
ll*@sos.state.tx.us wrote:
Hi Steve,

Thank you for your information. Your idea is helpful for me.
By the way, could I use "hiden" to handle this case?

Laya

Yes, some systems have done that, some have used a component of the URL
path, but you have to remember that the hidden items are available to
anyone using "view source" in their browser (or writing a client program
to do the equivalent thing), so your mechanism will be quite obvious to
hackers.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 5 '05 #7
lli
Steve,
You are right. I just test it. If users login application sucessfully,
then they can see hidden values by view source. Next time they can use
URL path ? key = value to open the second form. I will use session to
handle it.

By the way, do you write a book "Python Web Programming"? It is on my
desk. It's a great book.

Thanks,
Laya

Dec 6 '05 #8
lli
Thank you, fuzzyman.
LLi

Dec 6 '05 #9
ll*@sos.state.tx.us wrote:
Steve,
You are right. I just test it. If users login application sucessfully,
then they can see hidden values by view source. Next time they can use
URL path ? key = value to open the second form. I will use session to
handle it.

By the way, do you write a book "Python Web Programming"? It is on my
desk. It's a great book.


That was me. Glad you like it!

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 6 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
3
by: TC | last post by:
Hey Folks, I am using the following 4 Win32 APIs with a C# AddIn: FindWindow SetWindowLong SetForegroundWindow EnableWindow Within the AddIn, there are some winforms. I use these APIs to...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
2
by: paul.mason | last post by:
I was wondering if anyone else had come across this "feature" of .NET and if they had any idea what might be causing it. I've been writing my first C# Windows application (so if there's anything...
1
by: Flack | last post by:
Hey guys, Here is whats happening. I have a StringBuilder, a TextBox, and a TabControl with one TabPage. On my main form, I created and displayed a fairly big maze. While the app is solving...
10
by: Miro | last post by:
I wanted certain text boxes ( only certain ones ) to always be Trim'd so that spaces are not in the begining, nor the end of the text entered. I created my own "Handle ?" - i hope thats the...
0
by: =?Utf-8?B?c2Vy?= | last post by:
Hi, I am working on a windows application whose primary task is to apply all the properties of one control to another. Hence i am using the SetValue method of the PropertyDescriptor. The...
0
by: =?Utf-8?B?TWFyaw==?= | last post by:
Users of an in-house application we have written randomly get an Error creating window handle exception, and we've not been able to determine why this happens. A typical callstack is as follows: ...
2
by: rvarshney | last post by:
Hi All, Sometimes my application crashes with the exception Exception type: System.ComponentModel.Win32Exception Message: Error creating window handle. My Question to you guys are: 1. I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.