0
所以我一直在試圖爲客戶編寫一個CMS來更新他們的網站。我正在試圖讓更新新聞腳本起作用,並且我想知道如何讓腳本不僅更新新聞本身,而且還更新標題。下面是該腳本:更新CMS上的新聞
PHP:
//used to get data from previous page. $previous_title was so I can use it to set the where in the update query.
if($_GET['title']) {
$title = $_GET['title'];
$previous_title = $_GET['title'];
}
if($_POST['title']) {
$title = $_POST['title'];
$news = $_POST['news'];
//used to update both news and title
mysql_query("UPDATE `News` SET `Title`='$title', `Content`='$news' WHERE `Title`='$previous_title'");
header("Location: viewNews.php");
}
HTML:
<form id = "addNews" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="hidden" id="hidden" value="hidden" />
<input type="text" name="title" size="68" id = "title" value="<?php echo $query['Title'];?>"/><br/><br/>
<textarea name="news" id="news"><?php echo $query['Content'];?></textarea><br />
<input type="submit" value="Update News"/>
</form>
謝謝!
會有更新標題和新聞的方法嗎? – Andrew 2012-07-21 05:50:37