\nX-Mailer: PHP/" . phpversion(). "/qmail");
} // Insert Mode
// Fire Away, return results
if($debug){echo "\r\n\r\n\r\n\r\n\r\n\r\n";} // show SQL in comments in debug mode
$sql_action = db_exec_sql($sql,$db_database);
if($sql_action){ // Show message on success
?>
Success:
Your lesson plan has been sent successfully. Your entry will be reviewed for content by a moderator within the next 24 hours.
}
if(!$sql_action){ // Show message on failure
?>
Error:
An unknown error has occurred.
}
// Set form back to edit mode, on both add and edit
$_POST['mode'] = "null";
if($_POST['submitmode'] == "add"){
$_POST['editid'] = $_SESSION['lastinsert'];
}
// Process Group Permissions (Relation-Table)
if($sql_action){
// Delete Permissions
db_exec_sql("DELETE FROM group_member WHERE user_id = '$_POST[editid]'",$db_database);
// Add New Permissions
if($graduated_programs){
while(list($var,$value) = each($graduated_programs)){
$perm = explode("-",$value);
db_exec_sql("INSERT INTO group_member SET user_id='$_POST[editid]', group_id='$perm[0]', level='$perm[1]'",$db_database);
}
}
}
}
// If Missing Form Fields, warn
else{
// if($_POST['submitmode'] == "edit"){$_POST['mode'] = "null";$showform = true; $submitmode = "edit";} // Force back into edit mode if editing an existing record
?>
if ($userexists == true){ // Distinguish between 'existing user' error and 'required fields' error ?>
Error:
This email address already exists in our system. Please enter a unique email address then try again.
} else { ?>
Error:
There was an error with your submission. Please be sure that all required fields marked below are complete, then try again.
} ?>
}
}
/* [E] Add/Edit Processing */
}
// [E] OnSubmit Page Mode (add, edit, delete second step)
// [S] Initial Page Mode (add, edit, delete first step)
switch($_POST['mode']){
case "edit":
populateform($db_dbtable,$db_idfield,$_POST['editid'],$db_database); // Generate $_POST variables with all values
$showform = true;
$submitmode = "edit";
break;
case "null":
break;
default:
$showform = true;
$submitmode = "add";
break;
}
// [E] Initial Page Mode (add, edit, delete first step)
?>
/* [S] Showform: show form for edit & add */
if($showform){
// Strip slashes on re-load form to get rid of \', etc.
reset($_POST);
while(list($var,$value) = each($_POST)){
$_POST[$var] = str_replace(array('
','
'), "\r", stripslashes($value));
}
// ================================ //
// [S] Add Your Form Here //
// ================================ //
?>