how to check for all the fields in user registrations perl script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #16
    Originally posted by happyse27
    Hi Kevin,

    Not sure if I need to reinstall everything?? Cheers...

    Thanks and Best Rgds,
    Andrew
    Hi Andrew,

    To put it simply: I don't know. I've had Activeperl installed on my computer for years now. Read the PPM help files carefully and see if there are any sychronization options or other helpful suggestions. I've never had such a problem myself and you can read the help files as easily as I can.

    Comment

    • happyse27
      New Member
      • Sep 2008
      • 236

      #17
      Hi Kevin Guru,

      Thanks again. I think in PPM, i missed out the step "run marked action", activated this before I install the application and it works fine. The
      #Let's see if the email_address conforms to the RFC822 specification
      print (Email::Valid->address($email _address) ? 'yes' : 'no'); is correct, the final result printed yes or no.

      I shall try other modules as you recommended cheers...


      Thanks...
      Andrew

      Code:
      #!c:\perl\bin\perl.exe 
      #!/usr/bin/perl 
      ############################################ 
      ##                                        ## 
      ##     Account Manager LITE User Signup   ## 
      ##          by SiteInteractive.com        ## 
      ##    http://siteinteractive.com/contact  ## 
      ##                                        ## 
      ##             version:  1.09             ## 
      ##       last modified:  07/24/2002       ## 
      ##        copyright (c) 1998 - 2002       ## 
      ##                                        ## 
      ##    latest version is available from    ## 
      ##        http://SiteInteractive.com      ## 
      ##                                        ## 
      ############################################ 
      # 
      # Copyright 1998 Elite Host.  All Rights Reserved. 
      # 
      # TERMS OF USE  
      # 1. Account Manager is for licensed customers 
      # only. Customer may use Account Manager as many 
      # times as customer wishes, as long as customer owns or runs the web 
      # site that Account Manager is installed on.  Account 
      # Manager may not under any circumstances be sold 
      # or redistributed without the written consent of CGI Script Center and 
      # its owner Diran Alemshah. 
      # 
      # 2. CGI Script Center, at its own discresion, will decide if any terms  
      # of the this agreement have been violated by customer. Upon written e- 
      # mailed notification to Customer of Terms of Use violations, CGI 
      # Script Center may revoke customer's license to use Account Manager. 
      # In that event, Customer agrees to any and all of the following: 
      # 
      # a) Customers found in violation of this agreement, found reselling or 
      # redistributing Account Manager, or making  
      # Customers Members Area ID and password public to anyone in any  
      # manner will forfeit their Members area password and all rights to  
      # future versions of Account Manager. 
      #  
      # b). Customer will no longer be licensed to run any version of  
      # Account Manager.  
      # 
      # Indemnification 
      # 1. Customer agrees that it shall defend, indemnify, save and hold 
      # CGI Script Center, Elite Web Design and marketing, and any 
      # persons affiliated with either company, harmless from any and all 
      # demands, liabilities, losses, costs and claims, including reasonable 
      # attorney's fees asserted against CGI Script Center, its agents, its 
      # customers, officers and employees, that may arise or result from any 
      # service provided or performed or agreed to be performed or any product 
      # sold by customer, its agents, employees or assigns. Customer agrees to 
      # defend, indemnify and hold harmless CGI Script Center, its agents, 
      # its cusomters, officers, and employes,against 
      # liabilities arising out of; a) any injury to person or property caused 
      # by an products sold or  otherwise distributed in connection with CGI 
      # Script Center products; (b) any material supplied by customer 
      # infringing or allegedly infringing on the proprietary rights of a 
      # third party; c) copyright infringement and (d) any defective products 
      # sold to customer from CGI Script Center products. 
      # 
      # This program may not be distributed in whole or part, freely, for pay,  
      # or any other form of compensation. 
      # 
      ##################################################  ############### 
      # This version designed for Win32 systems (NT).  If you require 
      # a Unix version, please contact cgi@elitehost.com 
      ##################################################  ############### 
        
        
      ##################################################  ############ 
      # EDIT USER CONFIGURATIONS BELOW 
      ##################################################  ############ 
      
      # apache is in d DRIVE!!! not C
      
      #require "d:/program files/apache software foundation/apache2.2/cgi-bin/config.pl"; 
        
      # This completes this portion of your Account Manager setup 
      ##################################################  ############ 
      # DO NOT EDIT BELOW THIS LINE 
      ##################################################  ############ 
        
      use CGI; 
      use CGI::Carp qw(fatalsToBrowser); 
      use DBD::mysql;
      use DBI;
      use Email::Valid;
      
      
      my $query = CGI->new; 
        
      unless ($CGI::VERSION >= 2.47) {  
         error('Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.') 
      } 
       
      
      #SECTION B
      #=========================================
      #Database initialization and initial query
      my ($dbh, $data_source);  
      my $mysql_server_name   = 'localhost';  
      my $mysql_database_name = 'test';  
      my $mysql_user_name     = 'root';  
      my $mysql_password      = 'mysql1';  
      
      my $data_source = 'DBI:mysql:' . $mysql_database_name . ':' . $mysql_server_name;  
      my $dbh = DBI->connect( $data_source, $mysql_user_name, $mysql_password, {RaiseError=>1}) ||  die "$DBI::errstr";   
        
        
      
      
      #important line to pass email address from html to perl
      my $agree_field = $query->param("agree") || 'Annonymous'; 
      my $first_name = $query->param("fname") || 'Annonymous'; 
      my $last_name = $query->param("lname") || 'Annonymous'; 
      my $email_address = $query->param("email") || 'Annonymous'; 
      my $user_name = $query->param("username") || 'Annonymous'; 
      my $password = $query->param("pwd") || 'Annonymous'; 
      
      
      # End of Database initial Query
      #==========================================
      
      print $query->header(), 
            $query->start_html(-title=>'Input Successful'), 
            $query->p('Thanks for registrating your particulars with us!'), 
            $query->p("You Agree? : $agree_field:"),
            $query->p("Your First Name : $first_name"),
            $query->p("Your last Name : $last_name"), 
            $query->p("Your email address: $email_address"), 
            $query->p("Your username : $user_name"), 
            $query->p("Your Password : $password"), 
            $query->end_html; 
      
      sub error { 
         print $query->header(), 
               $query->start_html(-title=>'Error'), 
               shift, 
               $query->end_html; 
         exit(0); 
      } 
      
      
      my $sql = $dbh->prepare(qq{SELECT * FROM user_reg}); 
         $sql->execute(); 
      
      while (my @data = $sql->fetchrow_array()) { 
        
            # Print the date from the first two columns in the table 
            #print $data[0], "\t", $data[1], "<br>"; 
             print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "\t", $data[4], "\t", $data[5], "<br>";  
      } 
      
      1;
      
      
       $sql = $dbh->prepare(qq{insert into user_reg(agree_field, first_name, last_name, email_address, user_name, password) values ( "$agree_field", "$first_name", "$last_name", "$email_address", "$user_name", "$password") } );  
         $sql->execute() or die "$dbh->errstr\n";;  
        
      $sql = $dbh->prepare(qq{SELECT * FROM user_reg});  
       $sql->execute(); 
        
      
      while (my @data = $sql->fetchrow_array()){  
        
            # Print the date from the first four columns in the table  
            print $data[0], "\t", $data[1], "\t", $data[2], "\t", $data[3], "\t", $data[4], "\t", $data[5], "<br>";  
      
      }
      1;
      
      #Let's see if the email_address conforms to the RFC822 specification
      print (Email::Valid->address($email_address) ? 'yes' : 'no');

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #18
        Very good. Pretty soon you will be answering questions instead of asking them at the rate you're going. :)

        Comment

        • happyse27
          New Member
          • Sep 2008
          • 236

          #19
          Hi Kevin,

          Please dont dig at me. hee hee. I am abit really effective sometimes when I see these codes....

          Just want to complete the project. Cheers...


          Thanks and Best Rgds,
          Andrew

          Comment

          • happyse27
            New Member
            • Sep 2008
            • 236

            #20
            not really effective i meant... Typo... Hee hee

            Comment

            • KevinADC
              Recognized Expert Specialist
              • Jan 2007
              • 4092

              #21
              Originally posted by happyse27
              Hi Kevin,

              Please dont dig at me. hee hee. I am abit really effective sometimes when I see these codes....

              Just want to complete the project. Cheers...


              Thanks and Best Rgds,
              Andrew
              It wasn't a dig, it was a compliment. I meant that you seem to be learning quickly and in the near future you could be one of the people that is answering questions on forums, if that kind of thing interested you.

              Kind regards,
              Kevin

              Comment

              • happyse27
                New Member
                • Sep 2008
                • 236

                #22
                Hi Kevin,

                Thanks. Not likely but will seriously consider...

                Btw, I was trying about formsimple.pl, I compiled it but got the error below. I could not find the formvalidator:: simple module at all, but found the formvalidator module.

                Kindly advise why the package cant be found and the compilation error below.
                Thanks in advance


                Cheers...
                Andrew


                C:\Perl\bin>per l -c d:/formsimple.pl
                Can't locate FormValidator/Simple.pm in @INC (@INC contains: C:/Perl/site/lib C:
                /Perl/lib .) at d:/formsimple.pl line 2.
                BEGIN failed--compilation aborted at d:/formsimple.pl line 2.


                Code:
                #!C:\perl\bin\perl.exe
                use FormValidator::Simple;  
                
                   my $q = CGI->new;
                    $q->param( year  => 2005 );
                    $q->param( month =>   12 );
                    $q->param(   day =>   27 );
                
                    my $result = FormValidator::Simple->check( $q => [ 
                        { date => ['year', 'month', 'day'] } => [ 'DATE' ],
                    ] );
                
                    [% IF result.invalid('date') %]
                    <p>Set correct date.</p>
                    [% END %]

                Comment

                • numberwhun
                  Recognized Expert Moderator Specialist
                  • May 2007
                  • 3467

                  #23
                  That may end up being a case where PPM does not have the module available.

                  [soapbox]
                  That is one reason I hate active perl when working on Windows and now ONLY use Strawberry Perl. PPM is limited to what modules that ActiveState decides to port, thus they don't have all of them. So, if you want to be able to use any module, I would switch to Strawberry Perl
                  Installing modules with SP is as siimple as using the standard CPAN interface, thus, no limitations on modules available. :)
                  [/soapbox]

                  Regards,

                  Jeff

                  Comment

                  • KevinADC
                    Recognized Expert Specialist
                    • Jan 2007
                    • 4092

                    #24
                    PPM is limited to what modules that ActiveState decides to port
                    Not trying to split hairs Jeff but that is only true for modules Activestate decides to release as part of activeperl or via the activestate PPM repositories. Anyone is free to port modules over to PPM as you can see by checking modules available on other PPM repositories. DBD::mysql is an example. On activestate they have an old version 2.x (which only comes with perl 5.6) but the latest version is 4.x (on CPAN and one of the third party PPM repositories).

                    Of course the number of modules is still limited compared to CPAN and Strawberry perl is a good alternative for users that don't need commercial support or well tested industry standard performance. The makers of Strawberry perl are working on that though if you can judge by the website.

                    Comment

                    • happyse27
                      New Member
                      • Sep 2008
                      • 236

                      #25
                      hi Jeff and Kevin,

                      Thanks, but can I install both strawberry and activestate perl at the same time? Any problem to use both manager's packages simultaneously?


                      Cheers...
                      Andrew

                      Comment

                      • numberwhun
                        Recognized Expert Moderator Specialist
                        • May 2007
                        • 3467

                        #26
                        Originally posted by happyse27
                        hi Jeff and Kevin,

                        Thanks, but can I install both strawberry and activestate perl at the same time? Any problem to use both manager's packages simultaneously?


                        Cheers...
                        Andrew
                        It would be an issue because on Windows, the shebang line is not read unless its a CGI script and you are using the -T option. So, you can't implicitly say "use this one" like you can in Unix. It will take whichever one is in the path variable first unless you kick the script off with the absolute path to the Perl interpreter you want to use.

                        Comment

                        • numberwhun
                          Recognized Expert Moderator Specialist
                          • May 2007
                          • 3467

                          #27
                          Originally posted by KevinADC
                          Not trying to split hairs Jeff but that is only true for modules Activestate decides to release as part of activeperl or via the activestate PPM repositories. Anyone is free to port modules over to PPM as you can see by checking modules available on other PPM repositories. DBD::mysql is an example. On activestate they have an old version 2.x (which only comes with perl 5.6) but the latest version is 4.x (on CPAN and one of the third party PPM repositories).

                          Of course the number of modules is still limited compared to CPAN and Strawberry perl is a good alternative for users that don't need commercial support or well tested industry standard performance. The makers of Strawberry perl are working on that though if you can judge by the website.
                          **checks** Nope, no hairs damaged. :-) Although, I would rather only point to one place that has everything rather than have to point and a bunch of different repositories and still be limited.

                          I had more than one issue when I used ActiveState (before you told me about Strawberry Perl), where I couldn't find a module and voila, it had errors in its port or just wasnt ported altogether.

                          Comment

                          • KevinADC
                            Recognized Expert Specialist
                            • Jan 2007
                            • 4092

                            #28
                            I agree with Jeff. I wouldn't try installing Strawberry perl and Activeperl on the same machine unless you really know what you are doing. I'm not going to say its not possible, I did it once myself but it did create problems in the registry. Unfortunately I no longer remember what the problem was. I uninstalled Strawberry perl and activeperl and reinstalled activeperl to clear up whatever the problem was.

                            But that was also the first version of Strawberry perl. Newer versions seem to be working out bugs and you can now install it on a different drive besides the C drive like the version I had tried. So if you want to try it you do so at your own risk.

                            Comment

                            • KevinADC
                              Recognized Expert Specialist
                              • Jan 2007
                              • 4092

                              #29
                              Originally posted by numberwhun
                              **checks** Nope, no hairs damaged. :-) Although, I would rather only point to one place that has everything rather than have to point and a bunch of different repositories and still be limited.

                              I had more than one issue when I used ActiveState (before you told me about Strawberry Perl), where I couldn't find a module and voila, it had errors in its port or just wasnt ported altogether.
                              All true, but there are just as many and probably many more problematic modules posted on CPAN just because of the sheer number of modules. Anyone can post a module on CPAN that signs up with PAUSE , like yours truely, although after signing up and requesting a name space I never completed my intended module (File::Compare: :Util). Maybe someday I will.

                              There is lots and lots of crappy and buggy modules posted on CPAN. I always urge people to read the bug reports and reviews of modules and check the authors other modules before using a module. Many modules are uploaded and quickly abandoned never to be updated even when bugs are reported.

                              Comment

                              • numberwhun
                                Recognized Expert Moderator Specialist
                                • May 2007
                                • 3467

                                #30
                                Originally posted by KevinADC
                                All true, but there are just as many and probably many more problematic modules posted on CPAN just because of the sheer number of modules. Anyone can post a module on CPAN that signs up with PAUSE , like yours truely, although after signing up and requesting a name space I never completed my intended module (File::Compare: :Util). Maybe someday I will.

                                There is lots and lots of crappy and buggy modules posted on CPAN. I always urge people to read the bug reports and reviews of modules and check the authors other modules before using a module. Many modules are uploaded and quickly abandoned never to be updated even when bugs are reported.
                                I completely agree that there are a lot of modules out there that are, as you say, crap. As a general rule of thumb, you don't want to look at anything below version 1.0, although there are a few modules that are the exception to that rule and are avidly used by myself and many others in the coummunity due to their stability and usefulness. Just as an example.... case in point. That module is heavily used in the software that I support at work. While I am not 100% about all its capabilities, what it can do is simply amazing and I recommend it to anyone working with complex configuration files.

                                I just realized that we have (somewhat) hijacked this thread without meaning to. My appologies to the OP that started it.

                                Regards,

                                Jeff

                                Comment

                                Working...