Okay, that is partially my fault.
PHP Code:
//After teacher has entered marks...........
$message =<<<EMAIL_MESSAGE
'Dear Student, for your information, scores for your most recent examination have been uploaded. Please visit Med Buddy to view your score. Thank you.
EMAIL_MESSAGE;
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST['subject']))
apologize("Please select a subject");
// run update query setting the mark for the subject to $value
foreach ($_POST['mark'] as $studentid => $value)
{
$subjectExistsForStudent = query("SELECT scores FROM marks WHERE studentid = ? AND subject = ?", $studentid, $_POST['subject']);
if (sizeof($subjectExistsForStudent) === 0)
{
$result = query("INSERT INTO marks (studentid, subject, scores) VALUES (?, ?, ?)", $studentid, $_POST['subject'], $value);
if( $result===false)
{
apologize("Could not update student scores");
}
else
{
echo "Inserted Data for $studentid<br />";
$studentEmailAddress = query("SELECT email FROM users WHERE id = ?", $studentid);
$studentEmailAddress = $studentEmailAddress['0']["email"];
mail($studentEmailAddress, 'New Scores Uploaded!', $message);
}
}
else
{
$result = query("UPDATE marks SET scores = ? WHERE studentid = ? AND subject = ?", $value, $studentid, $_POST['subject']);
if( $result===false)
{
apologize("Could not update student scores");
}
else
{
echo "Updated Data for $studentid<br />";
$studentEmailAddress = query("SELECT email FROM users WHERE id = ?", $studentid);
$studentEmailAddress = $studentEmailAddress['0']["email"];
mail($studentEmailAddress, 'New Scores Uploaded!', $message);
}
}
}
die("Quit Processing");
Tell me what output you get for the above
Bookmarks