Re: Checking Form data
On Tue, 30 Jul 2002, Kipp, James wrote: What is the best way to validate form data. I have a form which the user enters dates like '08/01/2002'. What is the best way to make sure this format is entered. Should i use javascript here or regex? I heard about and started using Data::FormValidator. It returns a hash, I think of fields which were valid, an array of fields that were missing, and some other things, like invalid fields and unknown fields. The problem is, I don't know what to do with the information. I just enter $valid{$field} in the form wihout checking whether it exists, or is defined, or is true. -- Greg MathesonIf you're not making any mistakes, Chinmin College you must be making some mistake. Taiwan Penpals Archive URL: http://netcity.hinet.net/kurage -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple Selects to Perl Script
Hi I am having a most frustrating problem. I created a from with multiple selects using a perl script and passed the multiple selections to an array ie. @array1 = $q-param('type'). The array only contains the first selection and none of the others. How do I fix this? I have read a lot of documentation and it is supposed to work. What am I doing wrong? Regards Margaret -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Multiple Selects to Perl Script
are you sure all the values are associated with the name 'type' ? -Original Message- From: Margaret [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 9:27 AM To: [EMAIL PROTECTED] Subject: Multiple Selects to Perl Script Hi I am having a most frustrating problem. I created a from with multiple selects using a perl script and passed the multiple selections to an array ie. @array1 = $q-param('type'). The array only contains the first selection and none of the others. How do I fix this? I have read a lot of documentation and it is supposed to work. What am I doing wrong? Regards Margaret -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Post to a second CGI script
Jim, My recommendation is to write a session file on your server and pass the session id around with the browser variables. Now whether you use cookies, get or post to pass the session id, you don't have to be passing the actual username. If you don't want to have the user see the session id, put it in a cookie, and check to see if the cookie was created, if not, then send it via a form with post. If you want to be really sneaky about it, get your session id, then encrypt the id before giving it to the individual, so if they modify it, the decrypted version of what they pass back will not only not match theirs, but it cant match any one else's session id because it likely will not translate into a valid session id format. Good Luck, David - Original Message - From: Jim Lundeen [EMAIL PROTECTED] To: begin begin [EMAIL PROTECTED] Sent: Monday, July 29, 2002 6:06 PM Subject: Post to a second CGI script Hello All, I have 2 scripts. One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD and ACTION from an HTML form. That script looks in a user table in MySQL to verify the user. If valid, it passes them to MENU.CGI with LOGIN_USERNAME and a unique session number (USN). Here's the question: How to I post the LOGIN_USERNAME and USN to the MENU.CGI script? I don't want the user carrying the info around in the Location bar as ?USN=1234LOGIN_USERNAME=somebody -- I want it to be part of the user's Perl process if you know what I mean, so that if they hit RELOAD the values are still with them. Too, I don't want someone trying to modify the info if it were in the Location bar, so it needs to be a part of the post. Any advice would be much appreciated! Thanks! Jim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with the code please
On Tue, 30 Jul 2002 08:18:27 -0700, [EMAIL PROTECTED] (Soheil Shaghaghi) wrote: Can anyone please help me? It is really hard to tell what you want to do from the information you sent. Your cgi-script dosn't print out any html, nor does it print a location to go to. What do you want? Post the whole working script, or else we can't even guess. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checking Form data
What is the best way to validate form data. That would be a very very big topic here... I can't show the method, but can share some steps. Client Side 1. Check missing fields (Check it if js enabled) 2. Check pattern (js also do regex, but not powerful as Perl) Server Side 3. Pick up data ( you may have to deal with GET and POST ) ## Do 1 and 2 here if client side disabled js. 4. Check referer / session id /cookies / whatever (Aim to check where the form sign from) 5. Check yours own expectation on fields perference. That's all about on my point of view. I have a form which the user enters dates like '08/01/2002'. What is the best way to make sure this format is entered. Should i use javascript here or regex? None of them, you should create a select/opt menu. Then you even no need to check it, so you can put you focus to avoid 31/02/2002 etc. Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Why is not the window printed?
Hi all, I've made a script for uploading a file, and it uploads the file but it has a problem. I want to print another page that prints File uploading... while the file is uploading. Unfortunately I can't do that. After pressing the upload button, the page remains the same. It only appears Opening Page... in the task bar. Only after the file is uploaded it prints the result page, even a part of that page is printed before opening and printing the file. Do you have any idea why? Thank you. Here is the script: #!/usr/bin/perl -WT =author Teddy; Script made by Octavian Rasnita [EMAIL PROTECTED] =cut use lib /var/www/teddy/lib; use strict; use CGI; my $q = new CGI; #The max size of the uploaded file: $CGI::POST_MAX = 1024 * 1024 * 30; my $maxfile = $CGI::POST_MAX; #The folder with the uploaded files: my $outfolder = /var/www/teddy/html/up; my $hostroot = $ENV{'HTTP_HOST'}; #The web address of the folder with uploaded files: my $web_folder = http://$hostroot/up;; #The max size of the directory with uploaded files my $maxfolder = 1024 * 1024 * 100; #Max number of retries to rename (incrementing) the file: my $maxtries = 20; #Should this script announce by mail about this upload? my $sendmail = 1; #The email address used for announcing this upload: my $email_address = '[EMAIL PROTECTED]'; #The sender address of this message: my $email_from = '[EMAIL PROTECTED]'; #The address of the SMTP mail server: my $server = '127.0.0.1'; #The Hello address: my $hello = localhost; #The path to the sendmail program: my $mailprog = /usr/sbin/sendmail; #The subject of the message: my $email_subject = 'New file uploaded!'; ### End editing ### my $screen = $q - param ('screen'); my $script = $ENV{'SCRIPT_NAME'}; my $name = $q - param ('name'); my $email = $q - param ('email'); my $comments = $q - param ('comments'); my $filename; my $allpath; my $filesize; my $host; ### Start code ### my $dirsize = dir_size($outfolder); my $content_length = $ENV{'CONTENT_LENGTH'}; if (! $content_length) { $content_length = 0; } my $filled_space = $dirsize + $content_length; if ($content_length $maxfile) { #If the size of the file is bigger than the max size of a file that is allowed: my $freespace = $maxfile; $freespace = int(($freespace / 1048576) *10)/10; print Content-type: text/html\n\n; print eof; html lang=enheadtitleFile too big!/title/head The folder is full and there is not enough space for a file bigger than $freespace MB.br br If you want to upload a bigger file, please a href=mailto:$email_address;ask me how to do it./a /body/html eof exit; #End if: } if ($filled_space $maxfolder) { #If the size of the file + size of folder is bigger than the max allowed size of folder: my $freespace = $maxfolder - $dirsize; $freespace = int(($freespace / 1048576) *10)/10; print Content-type: text/html\n\n; print eof; html lang=enheadtitleFile too big!/title/head The folder is full and there is not enough space for a file bigger than $freespace MB.br br If you want to upload a bigger file, please a href=mailto:$email_address;ask me how to do it./a /body/html eof exit; } if (! $screen) { print_form; } elsif($screen eq 1) { get_host; upload; if ($sendmail eq 1) { send_mail; } } sub print_form { print Content-type: text/html\n\n; my $freespace = $maxfolder - $dirsize; if ($freespace $maxfile) { #Daca e loc mai mult decat marimea maxima a unui fisier permis: $freespace = $maxfile; $freespace = int(($freespace / 1048576) *10)/10; } else { #Daca e loc mai putin decat marimea unui fisier: $freespace = int(($freespace / 1048576) *10)/10; } print eof; html lang=enheadtitleUpload a file!/title/headbody Please make sure the file you want to upload is not bigger than $freespace MB.br If it is, it won't be saved on the server. It will be lost.br If you want to upload a bigger file than this limit, please a href=mailto:$email_address;ask me how to do it./a brbr You don't need to fill all the fields. You need just to type the correct path to a file you want to upload. br You can leave all the other fields blank if you want, but I would recommend filling them. brbr If you are using a screen reader, and if it can't read the Browse button, you have to activate the forms mode, then press tab, then space bar.br This will open the Browse for file windowbr form method=post enctype=multipart/form-data action=$script input type=hidden value=1 name=screen File name:input type=file name=file size=70 Your name: input type=text name=name size=30br Your email: input type=text name=email size=40br Comments: textarea name=comments rows=4 cols=70/textarea br input type=submit value=Upload file /form /body/html eof #end sub print_form: } sub upload { my ($filen, $ext); #Print the start of the page: $| = 1; print eof; Content-type: text/html !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html lang=en head titleUploading the file.../title link rel=stylesheet href=/teddy.css type=text/css
Re: Checking Form data
Although Perl/CPAN makes some good form handling modules available I think that the more client side data checking you can do the better. For date input I'd go with javascript, and I'd use an input calendar to control the data. See, for example, a prototype I'm working on at http://www.southwindssailing.com/pressgang/ which uses a nice javascript/DHTML input calendar by Lea Smart (www.totallysmartit.com). Kipp, James wrote: What is the best way to validate form data. I have a form which the user enters dates like '08/01/2002'. What is the best way to make sure this format is entered. Should i use javascript here or regex? -- Dr. John Griffiths \( ~ )7 The Teahouse of Experience MAILTO:[EMAIL PROTECTED] http://www.frontier.net/~grifftoe/ O, call back yesterday. Richard II, act 3, sc. 2. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checking Form data
Thanks for the reference. but as ealier mentioned , java script can be filtered out or shut off at the browser. i went ahead and made a validation routine in the CGI itself with regex and other tests. -Original Message- From: John Griffiths [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 1:20 PM To: Kipp, James Cc: '[EMAIL PROTECTED]' Subject: Re: Checking Form data Although Perl/CPAN makes some good form handling modules available I think that the more client side data checking you can do the better. For date input I'd go with javascript, and I'd use an input calendar to control the data. See, for example, a prototype I'm working on at http://www.southwindssailing.com/pressgang/ which uses a nice javascript/DHTML input calendar by Lea Smart (www.totallysmartit.com). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
flock(); with strict subs
How do I flock(); with strict subs in effect? Thanks, -- Kyle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Undefined subroutine main::param called
Thanks, my mistake. I orginally had the qw:/standard at the top but I changed it so anything using CGI.pm needed a $CGIquery but I forgot to add that before the param(con); On Wed, 31 Jul 2002 13:48:45 -0700, Soheil Shaghaghi [EMAIL PROTECTED] said: Sorry, I am pretty new to Perl myself, but you might want to try something like this: $q = new CGI; my $con = $q-param('con'); Soheil -Original Message- From: Kyle Babich [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 1:37 PM To: beginners-cgi Subject: Undefined subroutine main::param called This is what shows in my error log: Undefined subroutine main::param called at /home/sites/kmb/www/public_html/njindenial/index.pl line 10. This is like 10: my $con = param( con ); What should I change? I'm not quite sure what I should do. (I have attached the entire script if you think it is actually something else causing that problem.) Thank you again, -- Kyle -- Kyle -- Kyle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: It was a success, but only in Windows, not Unix.
This is coming from left field, and the gurus should chime in, and I have been reading up about IPC last couple of days so this is on the brain, but would setting up a signal handler (don't know what signal it would be receiving, obviously this would need to be determined) help? I would think that the END would be called, but if the script is receiving a signal then maybe in this case an END is never reached??? Random thoughts after a long day http://danconia.org Octavian Rasnita wrote: Hi all, After fighting a lot with a bigger script, I could make it work under Windows 2000, but it can't work under Red Hat 7.2 unfortunately. It is that script for downloading a file then delete it from the server. If the file finish downloading, it is deleted from the server using Windows and Linux. If the user starts downloading, or only opens the window that asks if they want to save or open the file, then cancel the download, the file is not deleted from the server under Linux. It is deleted from Windows however. I use Apache 2.0.3.6 in Windows, and Apache 1.32 in Linux. I've tried again that simple script version, and it works the same. I've attached it here below if you would like to take a look. I've tried putting the unlink $file line in an END { ... } but this block it is not executed if the download is cancelled. Do you have any idea if I have any solution to make it work? Thank you very much! Here is the script: #!/usr/bin/perl $| = 1; my $filename = $ENV{'QUERY_STRING'}; my $docroot = $ENV{'DOCUMENT_ROOT'}; my $file = $docroot/shopping/$filename; print eof; Content-type: application/zip Content-Disposition: attachment; filename=$filename eof open (FH, $file); binmode(FH); binmode(STDOUT); until (eof FH) { read (FH, my $buf, 1); print $buf; } close FH; END { unlink $file; } Teddy Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checking Form data
Kipp, James wrote: What is the best way to validate form data. I have a form which the user enters dates like '08/01/2002'. What is the best way to make sure this format is entered. Should i use javascript here or regex? i had some free time, so i decided to finish up some thoughts i have regarding validating form data. i've developed a simple module to perform basic validation and shown how to implement it. it's all available here: http://www.peacecomputers.com/form_checker/ please send any errata or general comments directly to me, not the list. many thanks to Eric Moore ([EMAIL PROTECTED]) for his help and patience during development. please note that this module doesn't really answer the question posed by the original poster, namely 'how do i validate a date?' imho, i'd do that like this (for slash-delimited dates only): use strict; use Date::Calc qw(check_date); my @date = qw( 08/02/2002 7/3/2003 13/3/2006 09/33/2002 al/df/ioji 09/14/66 ); for my $date (@date) { my ($month, $day, $year) = split /, $date; if (check_date($year,$month,$day)) { print $date is kosher\n; } else { print $date is uncool\n; } } OUTPUT 08/02/2002 is kosher 7/3/2003 is kosher 13/3/2006 is uncool 09/33/2002 is uncool Argument ioji isn't numeric in subroutine entry at try1.pl line 17. Argument al isn't numeric in subroutine entry at try1.pl line 17. Argument df isn't numeric in subroutine entry at try1.pl line 17. al/df/ioji is uncool 09/14/66 is kosher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Fw: Multiple Selects to Perl Script
Hi My html looks like this : form name='form1' method='POST' action='/cgi-bin/form.pl' . . select multiple name='type' size=5 optionone optiontwo optionthree etc /select . . /form Does this look right? Thanks Margaret - Original Message - From: Kipp, James [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 31, 2002 3:36 PM Subject: RE: Multiple Selects to Perl Script are you sure all the values are associated with the name 'type' ? -Original Message- From: Margaret [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 9:27 AM To: [EMAIL PROTECTED] Subject: Multiple Selects to Perl Script Hi I am having a most frustrating problem. I created a from with multiple selects using a perl script and passed the multiple selections to an array ie. @array1 = $q-param('type'). The array only contains the first selection and none of the others. How do I fix this? I have read a lot of documentation and it is supposed to work. What am I doing wrong? Regards Margaret -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]