Changed variables.

This commit is contained in:
2026-07-04 07:43:33 -07:00
parent 7ee47a0b1e
commit 4484f88d8d
21 changed files with 197 additions and 197 deletions
+22 -22
View File
@@ -5,53 +5,53 @@ use Nickyeoman\Validation;
$v = new Nickyeoman\Validation\Validate();
$url_success = '/novaconium/messages';
$url_error = '/novaconium/messages/edit/' . $post->get('id'); // Redirect back to the message edit form on error
$url_error = '/novaconium/messages/edit/' . $ctx->post->get('id'); // Redirect back to the message edit form on error
// Check if logged in
if (empty($session->get('username'))) {
$messages->error('You are not logged in');
$redirect->url('/novaconium/login');
if (empty($ctx->session->get('username'))) {
$ctx->messages->error('You are not logged in');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
// Check CSRF token
if ($session->get('token') != $post->get('token')) {
$messages->error('Invalid token');
$redirect->url($url_success);
if ($ctx->session->get('token') != $ctx->post->get('token')) {
$ctx->messages->error('Invalid token');
$ctx->redirect->url($url_success);
makeitso();
}
// Get POST data
$id = $post->get('id');
$name = $post->get('name');
$email = $post->get('email');
$message = $post->get('message');
$unread = !empty($post->get('unread')) ? 1 : 0;
$id = $ctx->post->get('id');
$name = $ctx->post->get('name');
$email = $ctx->post->get('email');
$message = $ctx->post->get('message');
$unread = !empty($ctx->post->get('unread')) ? 1 : 0;
// Validate required fields
if (empty($id) || empty($message) || empty($email)) {
$messages->error('One of the required fields was empty.');
$redirect->url($url_error);
$ctx->messages->error('One of the required fields was empty.');
$ctx->redirect->url($url_error);
makeitso();
}
try {
// Prepare update query
$query = "UPDATE `contactForm`
SET `name` = ?, `email` = ?, `message` = ?, `unread` = ?
$query = "UPDATE `contactForm`
SET `name` = ?, `email` = ?, `message` = ?, `unread` = ?
WHERE `id` = ?";
$params = [$name, $email, $message, $unread, $id];
$db->query($query, $params);
$ctx->db->query($query, $params);
$messages->notice('Message updated successfully');
$ctx->messages->notice('Message updated successfully');
} catch (Exception $e) {
$messages->error('Error updating message: ' . $e->getMessage());
$redirect->url($url_error);
} catch (\Exception $e) {
$ctx->messages->error('Error updating message: ' . $e->getMessage());
$ctx->redirect->url($url_error);
makeitso();
}
// Redirect to success page
$redirect->url($url_success);
$ctx->redirect->url($url_success);