SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: validate arrays

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validate arrays

    ok now I got this to work with arrays
    but I don't know how to setup in such way,
    when first array is ok, it goes to the next one.


    Code:
    PHP Code:
    <? // I have   2 arrays and want them to do: //   - if one is complete go to next: // array 1  \\          if ($checkMemberArray)                               {                                                                            $cemailAdr=strtolower($checkMemberArray['emailAdr']);                                          $memailAdr=strtolower($memberDataArray['emailAdr']);                                                               if ($cemailAdr!=$mcemailAdr )                                                                                           {                                         $command="sendAccountMail"$destPage=$PHP_SELF$label="here";                                             $quote="\"";                                             $clickString="onClick=".$quote."document.$formName1.operation.value='$command'; document.$formName1.action='$destPage'".$quote;                                             $hrefString="href='javascript:submitRoutine($quote$command$quote$quote$formName1$quote)'";                                             if (!$label) { $label=$command;}                                             $$command="<A $hrefString $clickString>$label</A>";                                         $errorArray['emailAdr']="Email Already registered";                                         $processMsg.="                                             <DIV class=processMsgError>                                                 .<P>                                                             Our records shows that this email has been registered for this event <P>                                                             Please provide different email address                                                 </DIV>                                             ";                                         }   //end of array 1  \\   // array 1  \\                 if ($checkMemberArray)                             {                                 $cFirst=strtolower($checkMemberArray['first']);                                 $cLast=strtolower($checkMemberArray['last']);                                 $mFirst=strtolower($memberDataArray['first']);                                 $mLast=strtolower($memberDataArray['last']);                                 if ($cFirst!=$mFirst or $cLast!=$mLast)                                     {                                         $command="sendAccountMail"$destPage=$PHP_SELF$label="here";                                             $quote="\"";                                             $clickString="onClick=".$quote."document.$formName1.operation.value='$command'; document.$formName1.action='$destPage'".$quote;                                             $hrefString="href='javascript:submitRoutine($quote$command$quote$quote$formName1$quote)'";                                             if (!$label) { $label=$command;}                                             $$command="<A $hrefString $clickString>$label</A>";                                         $errorArray['emailAdr']="Mismatch email and name";                                         $processMsg.="                                             <DIV class=processMsgError>                                             Email doesn't match our records. It has been registered already with different First & Last Name<P>                                            There needs to be different f.name and l.name for each of the registrants                                                                                                  </DIV>                                             ";                                         }                                     else                                         {                                             $memberDataArray['first']=$checkMemberArray['first'];                                             $memberDataArray['last']=$checkMemberArray['last'];                                             }                                 }                         }     //end of array 2  \\ ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Please don't put your PHP code blocks inside CODE blocks too, they make it impossible to read the code.

    I've also tidied up the code - remember to keep your code tidy, especially when using it as an example on a forum.
    PHP Code:
    <?
    // I have 2 arrays and want them to do:
    // - if one is complete go to next:
    // array 1\\
    if ($checkMemberArray){
        
    $cemailAdr strtolower($checkMemberArray['emailAdr']);
        
    $memailAdr strtolower($memberDataArray['emailAdr']);
        if (
    $cemailAdr != $mcemailAdr){
            
    $command "sendAccountMail";
            
    $destPage $_SERVER['PHP_SELF'];
            
    $label "here";
            
    $quote "\"";
            
    $clickString="onClick=".$quote."document.$formName1.operation.value='$command'; document.$formName1.action='$destPage'".$quote;
            
    $hrefString="href='javascript:submitRoutine($quote$command$quote$quote$formName1$quote)'";
            if (!
    $label) { $label=$command;}
            $
    $command="<A $hrefString $clickString>$label</A>";
            
    $errorArray['emailAdr']="Email Already registered";
            
    $processMsg.="
                <div class=processMsgError>
                    <p>
                        Our records shows that this email has been registered for this event <br />
                        Please provide different email address
                    </p>
                </div>
            "
    ;
        }
        
    //end of array 1\\
        // array 1\\
        
    if ($checkMemberArray){
            
    $cFirst=strtolower($checkMemberArray['first']);
            
    $cLast=strtolower($checkMemberArray['last']);
            
    $mFirst=strtolower($memberDataArray['first']);
            
    $mLast=strtolower($memberDataArray['last']);
            if (
    $cFirst!=$mFirst or $cLast!=$mLast){
                
    $command="sendAccountMail"$destPage=$PHP_SELF$label="here";
                
    $quote="\"";
                
    $clickString="onClick=".$quote."document.$formName1.operation.value='$command'; document.$formName1.action='$destPage'".$quote;
                
    $hrefString="href='javascript:submitRoutine($quote$command$quote$quote$formName1$quote)'";
                if (!
    $label) { $label=$command;}
                $
    $command="<A $hrefString $clickString>$label</A>";
                
    $errorArray['emailAdr']="Mismatch email and name";
                
    $processMsg.="
                    <DIV class=processMsgError>
                        Email doesn't match our records. It has been registered already with different First & Last Name<P>
                        There needs to be different f.name and l.name for each of the registrants
                    </DIV>
                "
    ;
            }else{
                
    $memberDataArray['first']=$checkMemberArray['first'];
                
    $memberDataArray['last']=$checkMemberArray['last'];
            }
        }
    }
    //end of array 2\\
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok,
    sorry. on most forums this type of combination will allow it to display
    correctly.

    Thanks !!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •