所以我一直在尝试为客户编写一个 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>
谢谢!