Public feed #531656

Something

public text v1 · immutable
Raw Edit
·published 2007-06-02 22:07 UTC
rendered paste body
$id = $_GET['id'];
if (!$id)
	{
		echo "Please select a news article to edit. Thanks!";
	}
else if ($id)
	{
		if ($_POST['go'])
			{
				$error = "";
				if (!$_POST['title'])
					{
						$error = "Title cannot be blank!";
					}
				if (!$_POST['name'])
					{
						$error .= "<br />Autor cannot be blank!";
					}
				if (!$_POST['message'])
					{
						$error .= "<br />You fogot to enter a message!";
					}  
				if ($error)
					{
						echo $error; 
					}
				else 
					{
						$title = $_POST['title'];
						$author = $_POST['author'];
						$post = $_POST['message'];
						$query = mysql_query("UPDATE `news_posts` SET `title` = '$title', `author` = '$author', `post` = '$post' WHERE `id` = $id");
						if ($query == TRUE)
							{
								echo "News Post Has Been Updated!";
							}
						else 
							{
							   echo "News post could not be updated.";
							}
					}
			}
	}
$query = mysql_query("SELECT * FROM `news_posts` WHERE `id` = '$id' LIMIT 1");
while ($r=mysql_fetch_assoc($query))
	{
		$title = $r['title'];
		$author = $r['author'];
		$post = $r['post'];
		echo "<h1 style='margin-bottom: 10px;'>Edit news</h1>
			  <form action='' method='post'>
			  <label for='title'>Title<span style='color: #d00000;'>*</span></label>
			  <input name='title' value='$title' type='text' maxlength='60'>
			  <br />
			  <label for='name'></label>
			  <input name='name' value='$author' type='hidden'>
			  <br />
			  <label for='message'>Message<span style='color: #d00000;'>*</span></label>
			  <textarea name='message' rows='7' cols='55'>$post</textarea>
			  <br />
			  <label for='submit'></label>
			  <input type='submit' name='go' value='Publish News'>
			  <input type='hidden' name='id' value='$id'>
			  <br /><br />
			  <span style='color: #D00000;'>*</span> indicates a required field.
			  </form>";	 
	}