//get var of posted info so user does not
//have to reinsert if if validation = false
if(!isset($_POST['FactionChanges'])){ $faction_name = ''; }
else { $faction_name = "".$_POST['factionname'].""; }
//without form submit, num_errors = 0
if(!isset($_POST['FactionChanges'])){ $num_errors = 0; }
//without form submit, success = 0
if(!isset($_POST['FactionChanges'])){ $success = 0; }
//error handling section [upon form submit]
if(isset($_POST['FactionChanges'])){
//deal with individual form section posts
//-->Faction Name
if(isset($_POST['factionname'])){
//set var for error
//array to use here
$errors = array();
$unsani_faction_name = $_POST['factionname'];
$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);
$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 < 3 || $string_length > 20){
$errors[] = 'Name: [between 3-20 characters]'; }
else{
$sql = mysql_query("SELECT * FROM ".TBL_TBL_FACTIONS."
WHERE f_name='$faction_name'");
$num_rows = mysql_num_rows($sql);
if ($num_rows > 0){ $errors[] = 'Name: [same faction name in existance]'; }
else { mysql_query("UPDATE ".TBL_FACTIONS." SET f_name='$faction_name'
WHERE f_id=$userfaction_id");
header("Location: ".$page_name."?section=actions");
//$success = 1; [DOES NOT work here]
}
}//else
}//if post factionname
$num_errors = count($errors);
if($num_errors === NULL){ $success = 1; }
}
//$success = 1; [works here]
if($num_errors > 0){ echo '<p class="error"><strong>Error:</strong>
The form could not be submitted because there are errors present</p>'; }
//add something here to only display sucess only if form is success
if($success == 1){ echo '<p class="success"><strong>Success:</strong>
Your faction changes have been made</p>'; }
I can't get the success box to display when a successful form input is submitted? I've done a little debugging myself, and I've inserted where I've tried inserting the success variable. I'm really quite stumped on this one.