我有一些基本的CMS用于一些新闻文章,基本上我的一些内容包含链接
<a href=""></a>
html,以便在写入页面时添加链接。这可能是我的内容被随机复制的原因吗?什么时候编辑?
这是我用来编辑的php。
include'includes/connection.php';
$pName = $_POST['pName'];
$pItem = $_POST['pItem'];
$pCategory = $_POST['pCategory'];
$pDate = $_POST['pDate'];
$pAuthor = $_POST['pAuthor'];
$pContent = $_POST['pContent'];
$Page = $_POST['Page'];
$id = $_POST['id'];
$pApproval = $_POST['pApproval'];
$pPriority = $_POST['pPriority'];
$pImage_Name = $_POST['pImage_Name'];
if($pItem != 2){
$updateq = "UPDATE sitecontent SET ID = '$pID', Post_Title = '$pName', Post_Year = '$pCategory', Date = '$pDate', Post_Author = '$pAuthor', Post_Content = '$pContent', Page = '$Page', Post_Approval = '$pApproval', Priority = '$pPriority', Image_Name = '$pImage_Name' WHERE ID = '$_POST[id]'";
$result = mysql_query($updateq) or die (mysql_error());
header("Location:admin.php");
}
if($pCategory = 2){
$updateq = "UPDATE reviews SET review_id = '$pID', review_title = '$pName', review_category = '$pCategory', review_content = '$pContent', review_image = '$piName', review_approval = '$pApproval' WHERE ID = '$_POST[id]'";
$result = mysql_query($updateq) or die (mysql_error());
header("Location:reviews-category.php");
}
这是发送数据之前的页面。
<form action="editp.php" method="POST" name="editform">
<table cellpadding="10" >
<tr>
<td width="86" valign="top" >
<label for="pName" style="padding:10px; ">Post Title</label></td>
<td width="550">
<input type="text" name="pName" style=" width:550px;border:#000099; margin:10px;" value="<?php echo $post['Post_Title']; ?>"/>
</td>
</tr>
<tr>
<td width="86" valign="top" >
<label for="pCategory" style="padding:10px; ">Category</label></td>
<td width="550">
<input type="text" name="pCategory" style=" width:50px;border:#000099; margin:10px;" value="<?php echo $post['Post_Year']; ?>"/>
</td>
</tr>
<tr>
<td>
<label for="pItem" style="padding:10px;">Item Type</label>
</td>
<td>
<select name="pItem" style="border:#000099; margin:10px;">
<option value="1">News</option>
<option value="2">Review</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="pName" style="padding:10px;">Article ID</label>
</td>
<td>
<input type="text" name="pID" style="border:#000099; margin:10px;" value="<?php echo $post['ID']; ?>"/>
</td>
</tr>
<tr>
<td>
<label for="pName" style="padding:10px;">Post Date</label>
</td>
<td>
<input type="text" name="pDate" style="border:#000099; margin:10px;" value="<?php echo $post['Date']; ?>">
</td>
</tr>
<td>
<label for="pName" style="padding:10px;">Post Author</label>
</td>
<td>
<input type="text" name="pAuthor" style="border:#000099; margin:10px;" value="<?php echo $post['Post_Author']; ?>"/>
</td>
</tr>
<tr>
<td>
<label for="pName" style="padding:10px;">Home Page</label>
</td>
<td>
<select name="Page" style="border:#000099; margin:10px;">
<option value="0">None</option>
<option value="1">Home</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="pPriority" style="padding:10px;">Home Priority</label>
</td>
<td>
<select name="pPriority" style="border:#000099; margin:10px;">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="pName" style="padding:10px;">Post Content</label>
</td>
<td>
<textarea style="width:550px; height:200px;border:#000099; margin:10px;" type="text" name="pContent" id="pContent" value="<?php echo $post['Post_Content']; ?>"><?php echo $post['Post_Content']; ?></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td style="padding:10px;">
<span id="btnStrong" style=" padding: 2px 8px;background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer;">Bold</span>
<span id="btnItalic" style=" padding: 2px 8px; background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer;">Italic</span>
<span id="btnPara" style=" padding: 2px 8px; background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer; margin-left:10px;">Paragraph</span>
<span id="btnBreak" style=" padding: 2px 8px; background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer; margin-left:10px;">Line Break</span>
<span id="btnLink" style=" padding: 2px 8px;background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer;">Link</span>
</td>
</tr>
<td>
<label for="pImage_Name" style="padding:10px;">Image Name</label>
</td>
<td>
<input type="text" name="pImage_Name" style="border:#000099; margin:10px; width:550px;" value="<?php echo $post['Image_Name']; ?>"/>
</td>
</tr>
<tr>
<td>
<label for="pApproval" style="padding:10px;">Approval</label>
</td>
<td>
<select name="pApproval" style="border:#000099; margin:10px;">
<option value="0">Pending</option>
<option value="1">Approved</option>
</select>
</td>
</tr>
<tr align="right">
<td><input type="hidden" name="id" value="<?php echo $_GET['id']; ?>"/></td>
<td colspan="2"><span style="margin-left:10px;">Please check the changes above before submitting</span><br/>
<input type="submit" name="go" value="Submit Changes" style=" padding: 2px 8px;background-color:#C00; color:#FFF; margin:10px;"/>
</td>
</tr>
</table>
</form>
答案 0 :(得分:5)
您确定要if($pCategory = 2){
而不是if($pCategory == 2){
吗?
您的if($pCategory = 2){
将始终评估为true,因此重复。
答案 1 :(得分:0)
您的更新可能会更改帖子的ID
SET ID = '$pID'
我无法看到您的代码中设置了$pID
的位置,但我敢打赌它与$_POST[id]
不一样。
你做分配 $ id = $ _POST ['id'];
也许你想分配给$pID
而不是$id
?
无论哪种方式,我都不会在UPDATE中包含ID。没有好处,也有引入错误的风险。