displaying new window with Perl
Hello,
I have figured out how to pass information from a form to a cgi perl program to check, and to display a new page with an error message if there is a problem with the data, using something like:
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n";
print "Invalid userid/password combination. Please try again.\n";
print "\n";
from my perl program. My question is this:
Is there a way to display this error message in a small window, rather than generating a new page? Thanks.
Bob
japhy posted this at 20:48 — 23rd March 2001.
They have: 161 posts
Joined: Dec 1999
You're asking for a client-side operation. You need to use javascript at some point for this.
Suzanne posted this at 23:39 — 23rd March 2001.
She has: 5,507 posts
Joined: Feb 2000
The issues as I see them: you can use JavaScript to verify a form before processing, but not when you want to verify passwords/usernames, because it's far too insecure.
To open a new window from the point of form submission, you would have to add JavaScript to the Perl script that says open this window and write this page to it. While it is doable, you would need to figure out first how to get the form to open a new window onClick or onSubmit (JavaScript), and then figure out how to put it into your Perl code.
From a user perspective, it would make more sense to have the Perl script add the comment at the top of the form, filling the form with all the entries the person has already entered, and let them give it another try. (Except for the password, you'll want to not include that.)
That give the use less clicking (the reason for the popUp, no?), and keeps their information, while also letting them know clearly what's wrong. You can use JavaScript to put the cursor in the right box.
hth,
Suzanne
Bob posted this at 03:23 — 24th March 2001.
They have: 117 posts
Joined: Feb 2000
Suzanne,
Thanks for your reply. You're right - I'm trying to use a perl script to verify the password because javascript is too insecure (although I could do it easily myself with javascript!). I like your idea of having the perl script simply write the message to the existing page, leaving the data already entered in place. Unfortunately, being new to perl, I have no idea how to do this. Can you point me to any examples of this being done, so I can get a starting point on how to go about doing it? Thanks again.
Bob
Suzanne posted this at 23:25 — 24th March 2001.
She has: 5,507 posts
Joined: Feb 2000
Hi, Bob,
In a general sort of way, what you would want to do is have the form reprinted by Perl in the case of an error, with the values (from the form) entered in the right places, like...
Then it writes out the form, but with error messages where needed, OR it goes on to the next phase. You can do this in separate scripts, or the same script.
To print the error notices where you want them to appear, put them in the code that's generated with if statements:
if ($email = "") {
print "You must enter a valid email address!";
}
You could have all the errors at the top, have them interspersed with the form, however you please.
I am answering you in general because I think if you understand *how* it works, it will be easy for you to implement it. I hope!
Suzanne
Bob posted this at 00:51 — 28th March 2001.
They have: 117 posts
Joined: Feb 2000
Suzanne,
Thanks for your help. I haven't had the chance to play with it yet. Hopefully this weekend, but I just wanted to say thanks for your time and help.
Bob
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.