<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/application_top.php'; // Create the answer class $myAnswer = new Answer(); try { // If they are saving the Information if ($_POST['submit'] == 'Save') { // Get all the Form Data $myAnswer->SetValues($_POST); $myAnswer->SetValue('user_id', $myUser->GetPrimary()); // Save the Make if ($myAnswer->Save()) { SetAlert('Answer Successfully Saved.', 'success'); LogAction('Saved Answer: ' . stripslashes($myAnswer->GetValue('question')), 1); header('location:' . PATH . 'answers'); die; } } // If Deleting if ($_POST['submit'] == 'Delete') { $myAnswer->SetValues($_POST); $name = stripslashes($myAnswer->GetValue('question')); // Remove from the DB if (!$myAnswer->Delete()) { throw new SimplException('Error deleting from the database, please try again.'); } // Everything went fine SetAlert('Answer Deleted Successfully', 'success'); LogAction('Deleted Answer: ' . $name, 1); header('location:' . PATH . 'answers');
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/application_top.php'; // Create the answer class $myAnswer = new Answer(); try { // If they are saving the Information if (isset($_POST['submit']) && $_POST['submit'] == 'Save') { // Get all the Form Data $myAnswer->SetValues($_POST); $myAnswer->SetValue('user_id', $myUser->GetPrimary()); // Save the Make if ($myAnswer->Save() && $myAnswer->Respond()) { SetAlert('Answer Successfully Saved.', 'success'); LogAction('Saved Answer: ' . stripslashes($myAnswer->GetValue('question')), 1); header('location:' . PATH . 'answers'); die; } } // If Deleting if (isset($_POST['submit']) && $_POST['submit'] == 'Delete') { $myAnswer->SetValues($_POST); $name = stripslashes($myAnswer->GetValue('question')); // Remove from the DB if (!$myAnswer->Delete()) { throw new SimplException('Error deleting from the database, please try again.'); } // Everything went fine SetAlert('Answer Deleted Successfully', 'success'); LogAction('Deleted Answer: ' . $name, 1); header('location:' . PATH . 'answers');