473,789 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2056
> 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.t x.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.t x.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.t x.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.t x.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
600
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 that it could not create a windows handle. On one machine the stacktrace is this:
6
3254
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." exception. The problem is that this exception isn't raised somewhere in a method, so it just shows up, and it causes the application to shut down. Is there anyway how to catch this kinds of exceptions? Can I put somewhere a
3
13725
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 set them as
15
4057
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
2
1507
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 so appalling in my code that it gives experienced developers a touch of the vapours, I hope you'll be indulgent!) I've written my own code to handle unexpected exceptions and I've added this as the handler to Application.ThreadException. It all...
1
8610
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 the maze, it appends each step it takes to the StringBuilder. When the maze is solved, the user can click a menu item to display the results. When the menu item is clicked, I set the TextBox Text value using the StringBuilder's ToString()...
10
1573
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 right terminology, and it works. Is this the right way to do this? I had to use DirectCast to get the textbox name. Private Sub TrimValues(ByVal sender As System.Object, ByVal e As EventArgs) _
0
1502
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 application works fine but throws an exception when the properties of combobox have to be set to the new control of the same type. The error stack is : Error creating window handle.
0
1831
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: : System.ComponentModel.Win32Exception: Error creating window handle. at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.TabPage.set_Visible(Boolean...
2
9129
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 not able to find out the root cause of it. Can somebody help me out? 2. How can I find the total window handle count? If I open crash dump and run the command !handle, it provides me 792 handle count. Further investigation (!DumpHeap -type...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.