Analyzing a form
I have a form with 7 fields, each having it's own dropdown menu. The fields are: option1: (1, 2) option2: (1, 2) option3: (1, 2) option4: (Yes, No) option4A: (1, 2) option5: (Yes, No) option6: (1, 2, 3, 4, 5,6) I am using this form to evaluate the eligibility of the user based on the input. The user passes in the following conditions: There are 2 simple requirements: One of the fields (options1, option2, option3,option4A) are equal to 1 and (option5=Yes or option62) So, we have: Option1=1 and (option5=Yes or option62) Option1=2 and option2=1 and (option5=Yes or option62) Option1=2 and option3=1 and (option5=Yes or option62) Option1=2 and option4=Yes and option4A=1 and (option5=Yes or option62) The user fails in the following conditions: Option5=No and Option62 Option1=2 and Option2=2 and Option3=2 and Option4=2 Now, here is what I am trying to get after the data is analyzed: All I want is to display a page that says Passed, or Failed with a message. Below is what I have so far: As you can see it's not completed yet, but I am not sure if I am doing it correctly and if there is another (better or easier way), and I am also confusing myself! sub html_fail { if (($option5 eq Yes and $option1 eq 1) || ($option5 eq Yes and $option2 eq 1) ||($option5 eq Yes and $option3 eq 1) || ($option5 eq Yes and $option4A eq 1)) { print END_HTML; good END_HTML } elsif ($option5 eq No and $option6 1 and $option1 eq 2) { print END_HTML; good END_HTML } else { print END_HTML; bad END_HTML } } Any help would be greatly appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Data check
Hi everyone, I have a form with a list of countries (dropdown menu) The countries are divided into 2 sections: For simplicity lets' sue these sets: Set 1: U.S. England, Canada, Germany Set 2: India, Japan, France, Saint Lucia, Northern Ireland The dropdown menu consists of the entire list. When the user submits the form, I want to check the country against the 2 sets, and point the user to different sections depending on which set the country is chosen. I know I can do this simple enough and just use the values 0, and 1 for each country in each set and check based on those values. But since I actually want to use the country somewhere else in the program, I am looking for an alternative way to do this. Can anyone please tell me how to do this? Thanks so much. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Retrieving data from files
Hi everyone, I am using a program that gets the user information and stores them. The program stores each user data in a separate file, like userid.tmp The data that is in each file looks like this: username#!#fullname#!#email#!#userid#!#registratingdate#...#!#n What I need to do is get the e-mail addresses and the names out of these files and store them all in one file. I have more than 10,000 files, so I can' really do this manually. Is there a way to do this with Perl? If so, can anyone please tell me how I can do this? Thanks so much. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Retrieving data from files
I am using a program that gets the user information and stores them. The program stores each user data in a separate file, like userid.tmp The data that is in each file looks like this: username#!#fullname#!#email#!#userid#!#registratingdate#...#!#n Seems strange to me, storing one of info in thousands of files. Why isn't this information stored in one file to begin with? -- Bad programming! This is why I want to change it :) Thanks for the hits :) Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question about dates
Hi everyone, I am trying to do some calculations based on the date the users have registered with the site. I want to sell a service. I have a form where the user comes to purchase the service. I can get the date from SQL database in any format and display it in form. At this point, when the user fills out the form and submits it, I want to look at the date. If the date is before August of 2002, the price should be set to $25.00, and if it's after August of 2002, it will be $50.00 Can anyone tell me how I can do this please? Note: The form does not use SQL itself. It's just CGI. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Question about dates
Thanks so much. I think it's a good way :) Now, I can't get the date printed in that format! Here is the code I have: sub DATEJOINEDRAW{ my %arg = @_; if ($arg{USER}) { my $UserID = $arg{USER}-get(field = 'UserID'); if ($UserID) { my %arg = @_; my $query = select RegistrationDate FROM USERS where UserID=$UserID;; my $sdb = $arg{DBOBJ}-prepare($query); $sdb-execute; my($reg)=$sdb-fetchrow; return $reg; } } return '0'; } This prints the date, but in order to get the raw data, I don't know what to do! I tried using the DATE_FORMAT, but it's not working: sub DATEJOINEDRAW{ my %arg = @_; if ($arg{USER}) { my $UserID = $arg{USER}-get(field = 'UserID'); if ($UserID) { my %arg = @_; my $query = select DATE_FORMAT(RegistrationDate, '%Y %M %D') FROM USERS where UserID=$UserID;; my $sdb = $arg{DBOBJ}-prepare($query); $sdb-execute; my($reg)=$sdb-fetchrow; return $reg; } } return '0'; } Any help would be appreciated. Soheil -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Monday, August 26, 2002 1:40 PM To: [EMAIL PROTECTED] Subject: Re: Question about dates on Mon, 26 Aug 2002 20:37:22 GMT, Soheil Shaghaghi wrote: I want to sell a service. I have a form where the user comes to purchase the service. I can get the date from SQL database in any format and display it in form. At this point, when the user fills out the form and submits it, I want to look at the date. If the date is before August of 2002, the price should be set to $25.00, and if it's after August of 2002, it will be $50.00 You may want to consider returning the date in two formats from your SQL query. One for comparing and one for displaying. If you take the format 'mmdd', the comparison is easy: if ($date lt '20020801') { $price = 25; } else { $price = 50; } You may also want to consider working in cents instead of dollars, to avoid rounding errors. -- felix -- 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: Online installer
Thanks Jim :) I've actually seen such scripts on the web, so I know it's possible. One thing that is not the job of this script is to actually look for server details. These should be determined by the user. Basically, the user is required to enter certain information in the form, like the path to Perl, sendmail,.. Then the program changes the necessary variables and begins the installation. I think it would become more clear to everyone if I show you an example: This is something close to what I am looking for: http://www.stepweb.com/installer/install.html Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Online installer
Hi Connie, Thanks for the reply. Well, I don't think the client side needs to have anything installed. I kind of know how it's supposed to be done I m just not sure who to write the code :) A little bit more details: 1. Let's say I have a directory structure for the program like this: program program/data program/test.cgi program/data/config.txt 2. The user enters his server ftp username/password The user also enters some server variables like path to Perl, sendmail,... The user also enters some variables like where he wants the application to be installed on the server. His server path, username/password, e-mail address... and submits the form. 3. Now, at my server, where the application is located, here is what I need to do: Method A: ftp to the user server, and change to the directory he specified in the form make some directories (program, data) copy all the files from my server to those directories set the permission on these files/directories Open the test.cgi and change the path to Perl, and save it. Open the config file and enter the variables the user entered and save it. Method B: Open the test.cgi and change the path to Perl, and save it. Open the config file and enter the variables the user entered and save it. ftp to the user server, and change to the directory he specified in the form make some directories (program, data) copy all the files from my server to those directories set the permission on these files/directories I guess this is it! Hopefully this makes it more clear :) Now, if the different servers are a problem, I don't mind starting from Unix based servers and just address those. Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Online installer
Dear Connie, Thanks so much :) It gives me a place to start :) I guess to make it simple, if the client gets disconnected, he can always start the process over. And if they make a mistake in filling out the form, I assume it just won't work, and the program will give errors. Thanks again, Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Online installer
Dear Connie, Hello and thanks again :) I just wanted to show you and everyone else who is interested in this subject a much better example: http://www.iwebsupport.com/cgi-bin/dsx.cgi?app=Installer And once again, your tip was great. Thanks. Actually the company above uses Net::FTP to do the transfer. Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Online installer
Dear Wiggins, Thanks :) It looks like it was my fault! It's just that I see this issue coming up in a lot of newsgroups, and forums. I see a lot of people ask questions, and once in a while some wise guy throws something out there! Once again, sorry :) Soheil Miscommunication I think is at the root. The way you stated the problem: quote I kind of know how it's supposed to be done I m just not sure who to write the code. /quote With the use of the phrase who to write the code implies that you had developed your proposed solution but were looking for someone else to actually right the code, which is why I suggested looking at the other list. I was not trying to imply that you shouldn't right the code or that we would not help with: 1) optimizations 2) problems you encountered related to your own development However having gone down this road I think you may have had a typo: who should have been how and all of a sudden your sentence takes on a whole new meaning. All about the attention to details to bad there isn't a use strict::English built into mail clients :-). Certainly not trying to discourage upcoming Perl programmers, but we have had posts before that were more suited to the jobs list than the help list. good luck with the project... http://danconia.org Soheil Shaghaghi wrote: Wiggins Wrote: snip This sounds like a question that probably shouldn't be addressed here, as this is a help forum, rather than a job posting forum?? Sounds like you know what you want, and it can certainly be done (in fact I would say there isn't much difficult about it), but we are really here to help with specific questions, getting people started using Perl, proposing optimized solutions, etc. Not for writing whole applications. snip I am sorry, but this is a FREE forum for all the Perl users. If questions like this bother you , you have 2 options: 1. Ignore them! 2. unsubscribe from the list! I don't want to start an issue over this, but if I am wrong, please everyone just tell me. I just don't see the point of this e-mail! It's just not helping me find a solution to my problem! I know I can hire programmers to write what I need! Do you tell all of the new Perl programmers to go hire someone to do what they want?! -- 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]
Online installer
Hello everyone, Can anyone tell me how to create an online cgi installer? Details: I have a program that want to install on my user's website upon their request. What I am looking for is some kind of form which the user fills out entering their ftp username/password, the directory where they want the program to be installed, the name of the directory, and some variables, like the color of the page, admin password, which will directly be inputted into the script after the installation is completed. Can anyone tell me how to do this, or if anyone has a sample to send me, it will be much appreciated. Thanks so much, Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with the code
Hi everyone, The following sub checks for bad e-mail address, and reports it: if (($self-{_Email} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $self-{_Email} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)) { $cool = undef; # No longer cool $message = $self-{_EmailInvalidMessage}; my $m = MessageText-new(Replacements = \%r, Message = $message); $self-{_ErrorEmail} = $m-print; } However, the code is rejecting the domains ending with .info, and .name (the reason is that it has 4 digits after the zero) Can someone please tell me how to change this code so it works please. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with the code please
Hello everyone, I want to be able to pass some variables from the page to a recommend it script, so I made a few adjustments like the following: use CGI; $q = new CGI; # $MAXNUM=5; $MAXNUM = $q-param('MAXNUM'); So, I pass the number of referrals from the URL, like: A HREF=/cgi-bin/referit.cgi?MAXNUM=10 Tell your friends about this page/A! Problem: Everything works the way it's supposed to, but after the user sends the form, the page reloads instead of going back to the referred page. It looks like the problem is the following: use CGI; $q = new CGI; But I don't know why, or how to fix it. Can anyone please help me? Thanks so much, Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problem with O_RDONLY
Hello everyone, I have a program that uses O_RDONLY extensively. After upgrading to Perl 5.6.1, every time this program is run, I see errors in the log files similar to this: Argument O_RDONLY isn't numeric in subroutine entry at /usr/local/lib/perl5/5.6.1/i386-freebsd/DB_File.pm line 259. Can anyone please tell me why I get this error, or how to solve it? Thanks so much, Soheil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
What's wrong with this code?
Hi everyone, Can anyone please tell me what the problem is with this code? Every time I run my program with this code in it, I get an error in the log files: DBD::mysql::st fetchrow_array failed: fetch() without execute() at IWeb/sqlengine.pm line 3395. sub SQL_Is_Sponsor { my ($link_id) = @_; my $is_sponsor = 0; if($link_id) { my $PriviledgeGroupID; $SQL = SELECT account FROM HS_links WHERE id = $link_id; $sth = $dbh-prepare($SQL) || IWEB::SQL_ERROR($SQL); $rc = $sth-execute || IWEB::SQL_ERROR($SQL); my($account) = $sth-fetchrow_array; if($account) { $SQL = SELECT PriviledgeGroupID FROM USERU WHERE UserName = '$account'; $sth = $dbh_bac-prepare($SQL) || IWEB::SQL_ERROR($SQL); $PriviledgeGroupID = $sth-fetchrow_array; } foreach my $level(split(/:/, $global{'yh_sponsor_levels'})) { if($PriviledgeGroupID == $level) { $is_sponsor = 1; } } return($is_sponsor); } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Upgrade to Perl
Hi List, I have been running Perl 5.6.0 for a while now, and today I decide to upgrade to 5.6.1! Everything works very good, but after the upgrade I can't see any changes to the system! I installed the upgrade in the same directory as Perl 5.6.0 Now, here are my problems, if anyone can please help me: 1. Perl still reports to be Version 5.6.0 2. I see so many Perl executables, and don't know which one the latest one is, or what I should do at this point to get the server to report Perl to be 5.6.1 /usr/bin/perlCreated: 12/25/2000 /usr/bin/perl5 Created: 11/20/2000 /usr/bin/perl5.00503Created: 11/20/2000 /usr/bin/perl5.6.0Created: 12/25/2000 /usr/local/bin/perlCreated: 07/24/2002 /usr/local/bin/perl5.6.0 Created: 12/22/2000 /usr/local/bin/perl5.6.1 Created: 07/24/2002 3. Is there a configuration somewhere I need to change? When I run perl -V, here is what I get: perl -V Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=freebsd, osvers=4.2-release, archname=i386-freebsd uname='freebsd www.domain.com 4.2-release freebsd 4.2-release #0: mon nov 20 13:02:55 gmt 2000 [EMAIL PROTECTED]:usrsrcsyscompilegeneric i386 ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='gcc', optimize='-O', gccversion=2.95.2 19991024 (release) cppflags='-fno-strict-aliasing -I/usr/local/include' ccflags ='-fno-strict-aliasing -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=true intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='gcc', ldflags ='-Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lm -lc -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under freebsd Compiled at Dec 25 2000 02:07:40 @INC: /usr/lib/perl5/5.6.0/i386-freebsd /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-freebsd /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
running tar from a browser
Hello everyone. Here is my problem, if anyone can please help me: Running, Linux. I am trying to write a simple backup program to backup the data from a directory. The script works from the command line. But when I try to run the same script from the browser, it doesn't work. I get this message: Data could not be backed up. Exited with the following message: No such file or directory The error logs say: tar: backup.tar: Permission denied tar: Error is not recoverable: exiting now Can anyone please help me? Here is the contents of the script: #!/usr/bin/perl my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize, $block); my $command1 = tar cvf backup.tar members templates reviews; system($command1); ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize, $block) = stat backup.tar; my $DAT_SIZE = $size; print Content-Type: text/html\n\n; if (-e backup.tar) { print CENTERH1Backup complete./H1/CENTERBLOCKQUOTEBLOCKQUOTE\n; print H4We recommend that you download the BLOCKQUOTEA HREF=\backup.tar\Data Backup File ($DAT_SIZE Bytes)/A/BLOCKQUOTEto your local computer for safe keeping.../H4\n; print /CENTERBLOCKQUOTENote: The backup file (backup.tar) is in the same directory as your CGI Programs Data. It is possible that you may not be able to download it using the link above (.cgi-bin directories will not allow downloads from them). If you cannot download it with the provided link, we recommend that you FTP into your server and retreive the file manually./BLOCKQUOTE/BLOCKQUOTE\n; } else { print CENTERH1Data could not be backed up./H1\n; print H4Exited with the following message: $!/H4\n; } exit 0; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
What's wrong with the code?
Hi everyone, Can anyone please tell me what's wrong with this code? When I try to submit the form, it just reloads the page. It never gets to the sub addreport Thanks so much. #!/usr/bin/perl # Locate and load required files eval { # Get the script location (for UNIX and Windows) ($0 =~ m,(.*)/[^/]+,)unshift (@INC, $1); # Get the script location (for Windows) ($0 =~ m,(.*)\\[^\\]+,) unshift (@INC, $1); # Load files require settings.cgi; require common.sub; }; # Read the form readform; reportit; ### SUBROUTINES ### # Display new member registration form sub reportit { # Load common vocabulary require $tmplpath/common.txt; # Load Registration Form template require $tmplpath/reportit.tmpl; # Smut filter indicator $showsmutswitch = a href=\javascript:popup('$scripturl/members.cgi?action=showsmut')\$commonv oc[35]/a$commonvoc[36] if $badwords; # Registration Form $FORM_SUB = qq(SCRIPT LANGUAGE=JavaScript !-- Hide from non-JavaScript browsers function Check_Data() { if (!document.adform.name.value || !document.adform.email.value || !document.adform.title.value || !document.adform.description.value) { alert($commonvoc[30]); return false; } else { return true; } } function popup(url) { newwindow=window.open(url,'name','height=200,width=300,scrollbars'); if (window.focus) {newwindow.focus()} } // Stop hiding --- /SCRIPT div align=center h3font face=$fontname size=$fontsizeb$tempvoc[0]/b/font/h3 form method=post action=$scripturl/reportit.cgi name=adform onSubmit=return Check_Data(); input type=hidden name=action value=addreport table width=$tablewidth border=0 cellspacing=1 cellpadding=3 tr td bgcolor=$headcolor colspan=2font face=$sfontname size=$sfontsize$tempvoc[1]/font/td /tr tr bgcolor=$primcolor tdfont face=$fontname size=$fontsizeb$commonvoc[66]*/b/font/td td input type=text name=name maxlength=35 size=30 /td /tr tr bgcolor=$seconcolor tdfont face=$fontname size=$fontsizeb$commonvoc[67]*/b/font/td td input type=text name=email maxlength=50 size=30 /td /tr tr bgcolor=$seconcolor tdfont face=$fontname size=$fontsizeb$commonvoc[68]*/b/font/td td bgcolor=$seconcolor input type=text name=title maxlength=100 size=30 /td /tr tr bgcolor=$primcolor tdfont face=$fontname size=$fontsizeb$commonvoc[69]*/b/font/td td textarea NAME=description WRAP=virtual ROWS=6 COLS=40/textarea /td /tr tr td bgcolor=$headcolor colspan=2font face=$sfontname size=$sfontsize$commonvoc[21] $showsmutswitch/font/td /tr /table br input type=submit name=submit value=$commonvoc[24] input type=button name=cancel value=$commonvoc[26] onClick=history.back() br /form /div); # Perform template substitutions $temphtml =~ s/\{FORM\}/$FORM_SUB/g; # Display the screen showscreen; } # Add new member to the database sub addreport { # Check referring URL urlcheck; # Check form fields if ($FORM{'name'} !~ /\S/) { push(@badfields, 3); } if ($FORM{'email'} !~ /[\w\-]+\@[\w\-]+\.[\w\-]+/) { push(@badfields, 4); } if ($FORM{'title'} !~ /\S/) { push(@badfields, 6); } if ($FORM{'description'} !~ /\S/) { push(@badfields, 7); } # Display errors, if any formerror; # Block Checker blocker($ENV{'REMOTE_ADDR'}, IP Address, $FORM{'email'}, E-Mail Address); # Check for bad/rude words smut_detect($FORM{'name'},$FORM{'email'},$FORM{'title'},$FORM{'description' }); # Strip html tags htmlstrip($FORM{'name'},$FORM{'email'},$FORM{'title'},$FORM{'description'}) ; # Get current time $curtime = time(); # Add member to the waiting list open(RLIST,$membpath/reportit.cgi) || err(Could not update reportit.cgi: $!); flock(RLIST,2); seek(RLIST,0,2); print RLIST $ENV{'REMOTE_ADDR'}\t$curtime\t$FORM{'name'}\t$FORM{'email'}\t$FORM{'title' }\t$FORM{'description'}\n; close(RLIST); # Notify administrator of new application if ($regadmin) { $msgtext = $FORM{'name'} has just applied to register with your Top Sites script!\n. ---\n\n . Note: this message was generated by Top Sites script.\n.