//deal with individual form section posts
//-->Faction Name
if(isset($_POST['factionname'])){
$unsani_faction_name = $_POST['faction'];
$new_faction_name = str_replace(",", "", $unsani_faction_name);
$faction_name = mysql_real_escape_string($new_faction_name);
$faction_name = preg_replace('/\s\s+/', ' ', $faction_name);//strips excess white space
$faction_name = stripslashes($faction_name);//strips slashes from name
//remove special chars except: "& $ £ ^ - ( )"
$faction_name = preg_replace('/[^a-z0-9\s£&$\^\(\)-]/i', '', $faction_name);
$string_length = strlen($faction_name);
if($string_length < 0 || $string_length > 20) {
echo '<strong>Error:</strong> Property name needs to be between 1-20 characters. ';
}else {
$sql = mysql_query("SELECT * FROM ".TBL_USERPROPBANKS." WHERE prop_name='$prop_name'");
$num_rows = mysql_num_rows($sql);
if ($num_rows > 0) {
echo '<strong>Error:</strong> Bank with the same name in existance. ';
}else {
mysql_query("UPDATE ".TBL_USERPROPBANKS." SET prop_name='$prop_name' WHERE prop_id='$bankid'");
header("Location: bank_cp.php?bankid=".$bankid."§ion=settings");
}
}
I'm working out my errors using the above method. What is (in your opinion) the most logical way to:
- Counting the number of errors
- And echoing/printing them inside a separate section of my layout to show each error message in a list?
All I can think of at the moment is assigning null values to unique vars then filling it with the unique error message if it does not meet my validation requirements (there will be 20+ different errors). Any ideas on this one?