VAlidate $_POST variables
Posted: Mon Jan 20, 2003 3:52 pm
Hi,
im posting cause im trying to find the error in the following code but i just can't see it
function CHECK_EMPTY($_POST){
if(!isset($_POST['First_Name']) && !isset($_POST['Last_Name'])){
$ErrorMsG[] = "Please Enter a Correct Name in the NAME Fields!";
}
if((!isset($_POST['Address1']) || !isset($_POST['Address2'])) && !isset($_POST['City'])){
$ErrorMsG[] = "Please Enter An Address";
}
if(!isset($_POST['Email'])){
$ErrorMsG[] = "Please Enter an Email Address in the EMAIL ADDRESS Field!";
}else{
$ErrorMsG[] = CHECK_EMAIL($_POST['Email']);
}
if(is_array($ErrorMsG)){
while(list($key,$val)=each($ErrorMsG)){
echo $key.",".$val;
}
return $ErrorMsG;
}
}
The above code validates some posted data from a form. The thing is i left some of the form data to test the validation which i get but while it lists the key it doesnt list the value and it isnt looping as i only get one key output.
can any one see wheres the error?
im posting cause im trying to find the error in the following code but i just can't see it
function CHECK_EMPTY($_POST){
if(!isset($_POST['First_Name']) && !isset($_POST['Last_Name'])){
$ErrorMsG[] = "Please Enter a Correct Name in the NAME Fields!";
}
if((!isset($_POST['Address1']) || !isset($_POST['Address2'])) && !isset($_POST['City'])){
$ErrorMsG[] = "Please Enter An Address";
}
if(!isset($_POST['Email'])){
$ErrorMsG[] = "Please Enter an Email Address in the EMAIL ADDRESS Field!";
}else{
$ErrorMsG[] = CHECK_EMAIL($_POST['Email']);
}
if(is_array($ErrorMsG)){
while(list($key,$val)=each($ErrorMsG)){
echo $key.",".$val;
}
return $ErrorMsG;
}
}
The above code validates some posted data from a form. The thing is i left some of the form data to test the validation which i get but while it lists the key it doesnt list the value and it isnt looping as i only get one key output.
can any one see wheres the error?