School: {$dbFeedbackSchool}
User: {$dbFeedbackUser}
Type: {$dbFeedbackType}
Content:

{$fd}

----{$rspv}

Love,
Solar Feedback System
EEMMAAIILLSS;
$headers = "To: Admin <{$to}>" . "\r\n";
$headers .= "From: Solar Feedback <{$from}>" . "\r\n";
if (!mail($to, $subject, $message, $headers)) {
    Bail('Couldn\'t send notification email.');
} else {
    DebugPrint('<p>Sending email...</p>');
}
// SHOW CONFIRMATION //
include 'feedback-received.html';
// FIXME there are many ways we can do this, change to be consistent with rest of site
/* FIXME an alternative method
    echo '<h3>Thank you for your feedback</h3>';

    if ( $dbFeedbackResponse == 1 )
    {
        echo '<p>We will get back to you soon</p>';
    }
     */
$con->close();
    if ($con->query($sql)) {
        if (!$con->select_db(DB_NAME)) {
            Bail('Couldn\'t select db after creating?? ' . $con->error);
        }
    } else {
        Bail('Couldn\'t create db: ' . $con->error);
    }
}
DebugPrint('<p>Selected db...</p>');
// Create table if necessary //
function TableExists($con, $tableName)
{
    return $con->query("SELECT 1 FROM `{$tableName}`");
}
if (!TableExists($con, TABLE_NAME)) {
    DebugPrint('<p>Creating table...</p>');
    $sql = 'CREATE TABLE `' . TABLE_NAME . '`
            (
                feedback_id INT NOT NULL AUTO_INCREMENT,
                PRIMARY KEY(feedback_id),
                school VARCHAR(50),
                user VARCHAR(50),
                type VARCHAR(15),
                content TEXT,
                response BOOL
            )';
    if (!$con->query($sql)) {
        Bail('Couldn\'t create table: ' . $con->error);
    }
}
echo '<h3>Solar Feedback Form</h3>';