I would like to recieve mail notification when someone updates a page. I am happy with the mail() part, but am confused as to where to put the script so that it only occurs on the push of the update button, rather than every time the page loads!
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO planner (name, email, subject, unit, objective, teacher_notes, activity_idea, term, week) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['name'], "text"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['subject'], "text"),
GetSQLValueString($HTTP_POST_VARS['unit'], "text"),
GetSQLValueString($HTTP_POST_VARS['objective'], "text"),
GetSQLValueString($HTTP_POST_VARS['teacher_notes'], "text"),
GetSQLValueString($HTTP_POST_VARS['activity_idea'], "text"),
GetSQLValueString($HTTP_POST_VARS['term'], "int"),
GetSQLValueString($HTTP_POST_VARS['week'], "int"));
mysql_select_db($database_zombie, $zombie);
$Result1 = mysql_query($insertSQL, $zombie) or die(mysql_error());
$insertGoTo = "check_plan.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Any help would be greatly appreciated