if ((isset($_GET['id'])) && (is_numeric($_GET['id']))){ $id = $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))){ $id = $_POST['id']; } else { exit("Please choose a news post to edit."); } if (isset($_POST['submitted'])){ $errors = array(); if (empty($_POST['title'])){ $errors[] = 'You forgot to enter a title.'; } else { $title = $_POST['title']; } if (empty($_POST['name'])){ $errors[] = 'You forgot to enter an author.'; } else { $name = $_POST['name']; } if (empty($_POST['message'])){ $errors[] = 'You forgot to enter a message'; } else { $post = $_POST['post']; } if (empty($errors)){ $query = "UPDATE news_posts SET title='$title', author='$author', post='$post' WHERE id=$id"; $result = mysql_query($query); if ($result){ echo "News Post Has Been Updated!"; } else { echo "News post could not be updated."; } } else { echo "News post could not be updated for the following reasons...
"; foreach ($errors as $msg) { echo " - $msg
\n"; } } } else { $query = "SELECT * FROM news_posts WHERE id = '$id'"; $result = mysql_query($query); $num = mysql_num_rows($result); $row = mysql_fetch_array($result, MYSQL_NUM); $title = $row['title']; $author = $row['author']; $post = $row['post']; if ($num == 1){ ?>

Edit news






* indicates a required field.