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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • happyse27
    New Member
    • Sep 2008
    • 236

    #31
    HI Kevin and all,

    Thanks man! So recommended to uninstall activestate perl and install strawberry? Quite confused.


    Thanks,
    Andrew

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #32
      Originally posted by happyse27
      HI Kevin and all,

      Thanks man! So recommended to uninstall activestate perl and install strawberry? Quite confused.


      Thanks,
      Andrew
      If you want to use Strawberry Perl over Active State, then yes, we recommend uninstalling one for the other. After you get Strawberry Perl installed, you can use these instructions for installing modules.

      Regards,

      Jeff

      Comment

      • happyse27
        New Member
        • Sep 2008
        • 236

        #33
        Hi Sir,

        Thanks! If I install strawwberry perl will the below module be available?

        use FormValidator:: Simple;


        Cheers...
        Andrew

        Comment

        • eWish
          Recognized Expert Contributor
          • Jul 2007
          • 973

          #34
          No, you will have to install it. It is not one of the core modules.

          --Kevin

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #35
            Originally posted by happyse27
            Hi Sir,

            Thanks! If I install strawwberry perl will the below module be available?

            use FormValidator:: Simple;


            Cheers...
            Andrew
            As Kevin said, only the core modules will initially be available. But, following the instructions in the link I sent, you can install other modules, including that one.

            Regards,

            jeff

            Comment

            • happyse27
              New Member
              • Sep 2008
              • 236

              #36
              Hi Jeff / Kevin,

              Thanks! I managed to uninstall activestate perl and install strawberry perl,

              Install the formvalidator:: simple module (long process though as they have many dependencies to install)

              used perl -c to check the sample script. but show the below error for print. Not sure what is the error as I changed many formats to print...


              Thanks in advance
              Andrew

              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')
                  
                  print "Set correct date";

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #37
                If you installed srawberryperl you have to change the shebang line to that of strawberry perl, it might be something like:
                Code:
                #!C:\strawberry-perl\bin\perl.exe
                if perl is in the command path then all you need is:

                Code:
                #!perl
                try the second one first

                Also note that there is no IF keyword in perl. All of perls builtin operators and keywords are all lowercase letters. So "IF" should be "if".

                You also have syntax errors which will not allow the script to compile, an "if" block is written one of two ways:

                Code:
                if (condition) {
                   expressions
                }
                or

                Code:
                expressions if (condition);

                Comment

                • happyse27
                  New Member
                  • Sep 2008
                  • 236

                  #38
                  Hi Thanks Kevin,

                  I used small case and it worked.

                  For those previous scripts proved working with activestate, now is not working using strawberry. The ppm modules may not be ported over.

                  Anything to take note?


                  Cheers...
                  Andrew

                  Comment

                  • numberwhun
                    Recognized Expert Moderator Specialist
                    • May 2007
                    • 3467

                    #39
                    Originally posted by KevinADC
                    If you installed srawberryperl you have to change the shebang line to that of strawberry perl, it might be something like:
                    Code:
                    #!C:\strawberry-perl\bin\perl.exe
                    if perl is in the command path then all you need is:

                    Code:
                    #!perl
                    Does it really matter? I don't think that the shebang line is read in the Windows world unless there is the -T for cgi scripts. Other than that, I think it is ignored and Perl should be kicked of with "perl <script>.pl" unless you have .pl files to automatically trigger perl. Either way, I don't think the shebang line matters most of the time in Windows.

                    Regards,

                    Jeff

                    Comment

                    • KevinADC
                      Recognized Expert Specialist
                      • Jan 2007
                      • 4092

                      #40
                      Originally posted by numberwhun
                      Does it really matter? I don't think that the shebang line is read in the Windows world unless there is the -T for cgi scripts. Other than that, I think it is ignored and Perl should be kicked of with "perl <script>.pl" unless you have .pl files to automatically trigger perl. Either way, I don't think the shebang line matters most of the time in Windows.

                      Regards,

                      Jeff

                      I'm confused by your -T reference. That has no affect on if the shebang line is read or not read. Windows ignores the shebang line all the time regardless of any switches used, but Apache does not ignore the shebang (it can be made to ignore it but thats another topic).

                      If he is running his CGI scripts from the command line then the shebang line is being ignored (regardless of the -T switch). If he runs them from Apache then the chances are 99.999% that the shebang line is being used.

                      Comment

                      • numberwhun
                        Recognized Expert Moderator Specialist
                        • May 2007
                        • 3467

                        #41
                        Originally posted by KevinADC
                        I'm confused by your -T reference. That has no affect on if the shebang line is read or not read. Windows ignores the shebang line all the time regardless of any switches used, but Apache does not ignore the shebang (it can be made to ignore it but thats another topic).

                        If he is running his CGI scripts from the command line then the shebang line is being ignored (regardless of the -T switch). If he runs them from Apache then the chances are 99.999% that the shebang line is being used.
                        Ah, see.... that was my confusion. I must have read a bad explanation at one point. Thanks for clearing that up.

                        Jeff

                        Comment

                        • happyse27
                          New Member
                          • Sep 2008
                          • 236

                          #42
                          Hi All,

                          Thanks! I tried to modify the script, end up having a error after many trials, the code is below. Not sure where is the problem?

                          Error
                          ====
                          C:\strawberry\p erl\bin>perl.ex e d:formsimple.pl
                          Undefined subroutine &main::inval id called at d:formsimple.pl line 16.



                          Best Rgds,
                          Andrew


                          Code:
                          #!C:\strawberry-perl\bin\perl.exe
                          use FormValidator::Simple;  
                          use CGI;
                          use cgi::Carp qw(fatalstoBrowser); 
                          #print "Content-type: text/html\n\n"; 
                          
                             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'))
                              {
                              print "Please set correct date";
                              }

                          Comment

                          • eWish
                            Recognized Expert Contributor
                            • Jul 2007
                            • 973

                            #43
                            Andrew,

                            This line is not correct and the cause of your error.
                            Code:
                            if (result.invalid('date'))
                            I would suggest that you revisit the documentation for examples.

                            The line above is suppose included in your template and looking more like this.
                            Code:
                                [% IF result.invalid('date') %]
                                <p>There is a problem with your date.</p>
                                [% END %]
                            Nor is this correct.
                            Code:
                            use cgi::Carp qw(fatalstoBrowser);
                            Should be
                            Code:
                            use CGI::Carp qw(fatalsToBrowser);
                            --Kevin

                            Comment

                            • KevinADC
                              Recognized Expert Specialist
                              • Jan 2007
                              • 4092

                              #44
                              eWish has pointed out a number of problems. Keep in mind this is programming, this is not something simple like HTML code. The syntax and case (UPPER and lower cas) of programming code is extremely important.

                              Reading a modules documentation can be difficult, especially for beginners. I can how you messed up your code after reading the FormValidator:: Simple documentation. The documentation is not perl beginner friendly.

                              I have never used the module so I can't help with how to use it.

                              Comment

                              • happyse27
                                New Member
                                • Sep 2008
                                • 236

                                #45
                                Hi All,

                                This is the correct code.


                                Thanks,
                                Andrew


                                Code:
                                #!C:\strawberry\perl\bin\perl.exe
                                use FormValidator::Simple;  
                                use CGI;
                                
                                   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'))
                                    {
                                    print "Please set correct date";
                                    }
                                Last edited by eWish; Oct 28 '08, 12:38 AM. Reason: Please use code tags

                                Comment

                                Working...