Реализовал вот так:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- // Getting of the news' data from DB for an ID from GET array.
- $getset = "SELECT * FROM `news` WHERE `id` = ".$_GET['key1']." LIMIT 1 ";
- // If the "CONFIRM EDIT" button is clicked
- if (isset($_POST['news_cat'], $_POST['title'], $_POST['author'], $_POST['short_description'], $_POST['full_description'], $_POST['editconf'], $_GET['key1'])) {
- $post = array('news_cat'=>$_POST['news_cat'], 'title'=>$_POST['title'], 'author'=>$_POST['author'], 'short_description'=>$_POST['short_description'], 'full_description'=>$_POST['full_description']);
- foreach ($post as $postk => $postv) {
- if ($postv == '') {
- $_POST[$postk] = $edit[$postk];
- }
- else {
- $_POST[$postk] = $postv;
- }
- }
- // Updating of news' details if the CONFIRM EDIT button is clicked
- query(" UPDATE `news` SET
- `news_add_date` = NOW(),
- `title` = '".arrrealstr($_POST['title'])."',
- `cat` = '".arrrealstr($_POST['news_cat'])."',
- `author` = '".arrrealstr($_POST['author'])."',
- `short_description` = '".arrrealstr($_POST['short_description'])."'
- WHERE `id` = ".$_GET['key1']."
- ");
- // Redirect to the news' list page
- $_SESSION['success'] = 'The choosen news has been successfully edited!';
- exit_redirect('news/news');
- }
- else { // If the "CONFIRM EDIT" button is not clicked
- $newsmes = 'Edit the news field below and click "CONFIRM EDIT" or go back to the news list. The fields with the "*" mark are required.';
- }
- ?>