That fixes things up. Thank you much both of you.
Now what about an ifelse for the $error_string?
Mine works but im sure that there is a better way.
Oh and do i need the last return ''; in the first function?
function test_field( $value , $field_name ,$preg_test )
{
if(!$value){
return ''.$field_name.' was left Blank. Please enter it below.<br>';
}
elseif(preg_match($preg_test,$value)){
return ''.$field_name.' has Invalid characters! Valid
characters are A-Z, 0-9 and punctuation!<BR>';
}
return '';
}
function test_all_fields($one, $two, $three, $four, $five, $six,
$seven, $eight, $nine, $ten, $eleven)
{
global $error_string;
$error_string .= test_field( $one , 'First Name' , '/[^a-z]/i' );
$error_string .= test_field( $two , 'Last Name' , '/[^a-z]/i' );
$error_string .= test_field( $three , 'Street Address' , '/[^a-z0-9 .-]/i' );
$error_string .= test_field( $four , 'City' , '/[^a-z]/i' );
$error_string .= test_field( $five , 'State' , '/[^a-z]/i' );
$error_string .= test_field( $six , 'Zip/Postal Code' , '/[^0-9]/i' );
$error_string .= test_field( $seven , 'Country' , '/[^a-z]/i' );
$error_string .= test_field( $eight , 'Email Address' , '/[^a-z0-9 .-@_]/i' );
$error_string .= test_field( $nine , 'Username' , '/[^a-z0-9]/i' );
$error_string .= test_field( $ten , 'Password' , '/[^a-z0-9]/i' );
$error_string .= test_field( $eleven , 'Our Question' , '/[^a-z0-9 .?!]/i' );
return $error_string;
}
test_all_fields($first_name, $last_name, $street_address, $city,
$state, $zipcode, $country, $email_address, $username,
$user_password, $info);
if( $error_string == '' ){
//This ifelse doesnt seem to be efficient.
//Considering I dont need to know the OK! if it works.
echo 'OK!';
}else{
echo $error_string;
include('join_form.php');
exit();
}