function process_edit_word() { if (!empty($_FILES['word_image']['name'])) { $image_file = wp_upload_bits($_FILES['word_image']['name'], null, @file_get_contents($_FILES['word_image']['tmp_name'])); $image_file_name = $image_file['file']; $pos = strpos($image_file_name, 'upload'); $image_file_name = substr_replace($image_file_name, '', 0, $pos); } if (!empty($_FILES['word_audio']['name'])) { $audio_file = wp_upload_bits($_FILES['word_audio']['name'], null, @file_get_contents($_FILES['word_audio']['tmp_name'])); $audio_file_name = $audio_file['file']; $pos = strpos($audio_file_name, 'upload'); $audio_file_name = substr_replace($audio_file_name, '', 0, $pos); } // Edit an existing word using the post data $word_id = $_POST['word_id']; $word_word = $_POST['word_name']; $word_description = trim($_POST['word_description']); $word_points = $_POST['word_points']; $word_domain_id = $_POST['domain_id']; $word_word_category_id = $_POST['category_id']; $word_image = $image_file_name; $word_audio = $audio_file_name; $word_description = trim(preg_replace('/\\s+/', ' ', $word_description)); // Get the id $return = update_word($word_id, $word_word, $word_description, $word_points, $word_domain_id, $word_word_category_id, $word_image, $word_audio); if ($return) { wp_redirect(admin_url('admin.php?page=word_menu&settings-saved')); } else { wp_redirect(admin_url('admin.php?page=word_menu&error')); } }
<?php require_once 'incl/functions.php'; ?> <?php if (isset($_POST['submit'])) { //checks if a form named submit has been added delete_word($_POST); } if (isset($_POST['edit_submit'])) { //checks if a form named submit has been added update_word($_POST); } ?> <title>Dictionary | The Front Page!</title> <div class = "head"> <link rel="stylesheet" href="jquery/jquery-ui.min.css"> <script src="jquery/external/jquery/jquery.js"></script> <script src="jquery/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="style.css"> <link href='https://fonts.googleapis.com/css?family=Tinos:400,400italic|Crete+Round:400,400italic|Lora:400,400italic|Bitter:400,400italic|Raleway:400,500,600|Fjalla+One|Archivo+Narrow:400,700|Telex' rel='stylesheet' type='text/css'> <div class = "search"> <div class = "social_icon"><img src="images/search.png" class = "icon" title="search" /></div> <div class = "social_icon"><input type="search" id="mySearch" placeholder="Search"></div> </div> <div class = "logo"> <div class = "logo_container"><a href = "index.php"><img src = "images/logo2.png" alt = "logo" id = "logoimg"/></a></div>