good php validation

  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i have a form with 'validation' on it. thing is it doesnt work at all. here is the code:
Code: [ Select ]
for($i=0;$i<count($required_fields);$i++) {
  if(!isset($_POST[$required_fields[$i]]) || $_POST[$required_fields[$i]]=='') {
    $err[$errCount]='You must provide a '.$_POST[$required_fields[$i]];
    $errCount   = $errCount + 1;
  }else{
    $field[$fineCount] = $_POST[$required_fields[$i]];
    $fineCount  = $fineCount + 1;
  }
}
if ($errCount>0) {
  //output error code
  $strOut = "Your submision generated the following errors:<br>";
  for ($i=0;$i<count($err);$i++){
    $strOut .= $err[$i] . "<br>";
  }
}else{ do whatever
  1. for($i=0;$i<count($required_fields);$i++) {
  2.   if(!isset($_POST[$required_fields[$i]]) || $_POST[$required_fields[$i]]=='') {
  3.     $err[$errCount]='You must provide a '.$_POST[$required_fields[$i]];
  4.     $errCount   = $errCount + 1;
  5.   }else{
  6.     $field[$fineCount] = $_POST[$required_fields[$i]];
  7.     $fineCount  = $fineCount + 1;
  8.   }
  9. }
  10. if ($errCount>0) {
  11.   //output error code
  12.   $strOut = "Your submision generated the following errors:<br>";
  13.   for ($i=0;$i<count($err);$i++){
  14.     $strOut .= $err[$i] . "<br>";
  15.   }
  16. }else{ do whatever


this code doesnt work. the page just hangs and doesnt refresh at all. anybody got any better suggestions?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

PHP Code: [ Select ]
 
<?php
 
for($i=0;$i<count($required_fields);$i++) {
 
    if(!isset($_POST[$required_fields[$i]]) || $_POST[$required_fields[$i]]=='') {
 
        $err[$errCount]='You must provide a '.$required_fields[$i];
 
        $errCount     = $errCount + 1;
 
    }else{
 
        $field[$fineCount] = $_POST[$required_fields[$i]];
 
        $fineCount    = $fineCount + 1;
 
    }
 
}
 
if ($errCount>0) {
 
    //output error code
 
    $strOut = "Your submision generated the following errors:<br>";
 
    for ($i=0;$i<count($err);$i++){
 
        $strOut .= $err[$i] . "<br>";
 
    }
 
}else{ do whatever }
 
?>
 
 
  1.  
  2. <?php
  3.  
  4. for($i=0;$i<count($required_fields);$i++) {
  5.  
  6.     if(!isset($_POST[$required_fields[$i]]) || $_POST[$required_fields[$i]]=='') {
  7.  
  8.         $err[$errCount]='You must provide a '.$required_fields[$i];
  9.  
  10.         $errCount     = $errCount + 1;
  11.  
  12.     }else{
  13.  
  14.         $field[$fineCount] = $_POST[$required_fields[$i]];
  15.  
  16.         $fineCount    = $fineCount + 1;
  17.  
  18.     }
  19.  
  20. }
  21.  
  22. if ($errCount>0) {
  23.  
  24.     //output error code
  25.  
  26.     $strOut = "Your submision generated the following errors:<br>";
  27.  
  28.     for ($i=0;$i<count($err);$i++){
  29.  
  30.         $strOut .= $err[$i] . "<br>";
  31.  
  32.     }
  33.  
  34. }else{ do whatever }
  35.  
  36. ?>
  37.  
  38.  


Sorry about the previous version there was a bug but I have fixed it both here and on the other pages you have posted

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 87 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.