File: /home/httpd/html/xdudes.com/admin/edit_email_content.php
<?php
require "db.php";
if (!is_numeric($_GET['id'])) {
exit();
}
$id = (int) $_GET['id'];
$row = dbRow("SELECT `email_translations`.*, `email_templates`.`name` FROM `email_translations` INNER JOIN `email_templates` ON `email_translations`.`template_id` = `email_templates`.`record_num` WHERE `email_translations`.`record_num` = '$id'");
if (!is_array($row)) {
setMessage("E-mail Template ID $id does not exist!", 'error');
pageNotFound(true);
}
if (isset($_POST['formSubmit'])) {
$_POST = array_map_array('trim', $_POST);
if ($_POST['subject'] == "") {
setMessage('Subject cannot be empty!', 'error');
}
if ($_POST['body'] == "") {
setMessage('Body cannot be empty!', 'error');
}
if (!getMessages(false, 'error')) {
dbUpdate(email_translations, array(
'subject' => $_POST['subject'],
'body' => $_POST['body'],
'record_num' => $id,
));
setMessage('Email has been updated. <a href="' . $basehttp . '/admin/email_templates.php"><b>Click here to return to Emails Templates</b></a>');
header("Location: ".$_SERVER['REQUEST_URI']);
exit();
}
}
$_POST += $row;
entities_walk($_POST);
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="email_templates.php">Email Templates</a></span>
</div>
</div>
<div class="content-outer">
<h2>Edit<strong>Email</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<form action="" method="POST" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th colspan="2">Email "<?php echo $_POST['name'] ?>"</th>
</tr>
</thead>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" value="<?php echo $_POST['subject']; ?>" required /></td>
</tr>
<tr>
<td>Body:</td>
<td>
<textarea name="body" id="form-body" class="large editor-enabled"><?php echo $_POST['body']; ?></textarea>
<div class="field-info">
<table>
<tr>
<td>%basehttp</td>
<td><?php echo $basehttp ?></td>
</tr>
<tr>
<td>%sitename</td>
<td><?php echo $sitename ?></td>
</tr>
<tr>
<td>%admin_email</td>
<td><?php echo $admin_email ?></td>
</tr>
<tr>
<td>%noreply_email</td>
<td><?php echo $noreply_email ?></td>
</tr>
<tr>
<td>%username, %email, %age, %gender, %description, %name</td>
<td><?php echo 'From user\'s profile.' ?></td>
</tr>
</table>
</div>
</td>
</tr>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="id" value="<? echo $id; ?>">
<input type="hidden" name="formSubmit" value="1">
<button type="submit" class="btn action-save">Submit</button>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php require "footer.php"; ?>