function custom_slide_update() { $post = new posts(); if (isset($_POST['action'])) { $post_id = $_POST['post_id']; $fields = $_POST['slide_fields']; foreach ($fields as $field) { $post_data[] = $field['name'] . '::' . $field['value'] . '#'; } $data['comment'] = implode('', $post_data); if ($post->update_post($data, array('id' => $post_id))) { echo 'update'; } else { echo 'error'; } } }
<?php $post = new posts(); global $session, $main_db; if (isset($_POST['submit'])) { $data['post_title'] = $_POST['contact_title']; $data['post_content'] = $_POST['address_content']; $data['post_type'] = 'tab'; $data['post_position'] = $_POST['tab_position']; if (isset($_GET['id'])) { if ($post->update_post($data, array('id' => $_GET['id']))) { $session->message("Your tab update successful! "); safe_redirect(admin_url('new-post') . '?post=tab&id=' . $_GET['id']); } else { var_dump($main_db->last_query); exit; } } else { if ($post->insert_posts($data)) { $session->message("Your tab has been created!"); safe_redirect(admin_url('new-post') . '?post=tab&id=' . $main_db->insert_id); } else { var_dump($main_db->last_query); exit; } } } $current_post = NULL; if (isset($_GET['id'])) { $current_post = $post->get_post_by_id($_GET['id']); }
<?php include 'header.php'; include 'sidebar.php'; global $session; $post = new posts(); $current_post = $post->get_single_post_by('terms'); if (isset($_POST['submit']) || isset($_POST['update'])) { $data['post_content'] = $_POST['term_content']; $data['post_title'] = $_POST['term_title']; $data['post_type'] = 'terms'; if (isset($_POST['update'])) { if ($post->update_post($data, array('id' => $current_post->id))) { $session->message('Term and service update successfull'); safe_redirect(admin_url('terms')); } } else { if ($post->insert_posts($data)) { $session->message('Terms and services posts successfull! '); safe_redirect(admin_url('terms')); } else { $session->message($main_db->last_query); safe_redirect(admin_url('terms')); } } } ?> <!-- Page content --> <div id="page-content-wrapper"> <!-- Keep all page content within the page-content inset div! --> <div class="page-content inset">