Thank you for taking the time to read this....
My task is to validate a php form and process it in a new page "process-comp.php" I can validate it ok in JS and I can validate it OK in PHP. The problem: If it validates incorrectly it prompts the errors. if it validates correctly it does not go anywhere and do not process the form
I need to know how to redirect the form and its values to "process-comp.php" once the form is completed and validated.
If there are error I do not want the user to enter the info again in the blank fields just to correct the incorrect fields.
And how do i protect against XSS (Cross Site Scripting) attacks,
Please find code below:
    <?PHP
   require_once ("formvalidator.php");
   $show_form=true;
   if(isset($_POST['Submit']))
   {// We need to validate only after the form is submitted
   //   
   // The first argument is the name of the input field in the form. 
   // The second argument is the validation descriptor that tells the type of the validation required. 
   // The third argument 
   // is the error message to be displayed if the validation fails. 
   //
   //Setup Server side Validations
       //Please note that the element name is case sensitive 
       $validator = new FormValidator();
       $validator->addValidation("FIRSTNAME_FIELD","req","Please enter first name");
       $validator->addValidation("LASTNAME_FIELD","req","Please neter your surname");    
       $validator->addValidation("EMAIL_FIELD","email","Enter a valid email value");
       $validator->addValidation("EMAIL_FIELD","req","Please enter an Email");
       $validator->addValidation("STORE_NAME_FIELD","req","Please select a store");
       //Then validate the form
       if($validator->ValidateForm())
       {
    // 
   // How do i make it to process the form it is correctly to "process-page.php"
    //
       }
       else
       {
           echo "<B>Validation Errors:</B>";
           $error_hash = $validator->GetErrors();
           foreach($error_hash as $inpname => $inp_err)
           {
             echo "<p>$inpname : $inp_err</p>\n";
           }
       }
   }
   if(true == $show_form)
   {
   ?> 
   <form class="" name="emvForm" id="emvForm"  action="" method="POST" style="" >
        <table width="380" border="0" cellspacing="10" cellpadding="" style="">
     <tr>
       <td class="form-comp"><label for="FIRSTNAME_FIELD" style="">First name*</label></td>
       <td><input type="text"  class="required nameaa " id="FIRSTNAME_FIELD" name="FIRSTNAME_FIELD" value="" size="25" maxlength="64" style=""></td>
     </tr>
     <tr>
       <td class="form-comp"><label for="LASTNAME_FIELD">Surname* </label></td>
       <td><input type="text" class="required nameaa" id="LASTNAME_FIELD" name="LASTNAME_FIELD" value="" size="25" maxlength="64" style=""></td>
     </tr>
     <tr>
       <td class="form-comp"><label for="EMAIL_FIELD">Email*</label></td>
       <td><input type="text" id="EMAIL_FIELD" class="required email" name="EMAIL_FIELD" value="" size="25" maxlength="64" style=""></td>
     </tr>
     <tr>
       <td class="form-comp"><label for="STORE_NAME_FIELD">Select shop*</label></td>
       <td><select id="STORE_NAME_FIELD" name="STORE_NAME_FIELD" class="required" style="">
         <option selected disabled="disabled" value="">Select shop</option>
         <option value="Aberdeen |T: 0123456789 | 345 Lorem High St EFG 456">Aberdeen </option>
         <option value="Acton | T: 0123456789 | 123 Ipsum High St ABD 123">Acton </option>
         <option value="Aldgate">Aldgate </option>
         <option value="Ashford">Ashford </option>
         <option value="Aylesbury">Aylesbury </option>
         <option value="Baker Street">Baker Street </option>
       </select></td>
     </tr>
     <tr>
       <td> <label for="STORE_NAME_FIELD"> </label>
       </td>
       <td>
        <input type='submit' name='Submit' value='Submit form' style=" cursor:pointer;">
       </td>
     </tr>
   </table>
         <input type="hidden" id="SOURCE_FIELD" name="SOURCE_FIELD" value="St-Petes">
         <input type="hidden" id="PROMO_FIELD" name="PROMO_FIELD" value="<?php echo($Promo); ?>">
         <input type="hidden" id="PROMO2_FIELD" name="PROMO2_FIELD" value="<?php echo($Promo2); ?>">
   </form>
   <?PHP
   }//true == $show_form
   ?>
   </table>
 
     
     
     
    