我的編輯頁面無法正常工作。我一直在收到 注意:未定義的變量。如果我把形式關閉每日新聞的形式只是disappers當我點擊更新按鈕我的編輯頁面無法正常工作
注意:未定義的變量:POST_TITLE在C:\ WAMP \ WWW \說服\ ADMIN \上線edit_posts.php 57
0down voteaccept
我必須說實話我很新的PHP。實際上,這段代碼來自我正在遵循的教程http://www.youtube.com/watch?v=oZ2KZRHASdQ。不幸的是視頻凍結前6分鐘,這就是爲什麼我要求幫助
我所做的是
<?php } } ?>
看來,當我編輯的帖子到現在工作
但現在我得到這個錯誤
注意:未定義的索引:edit_form在C:\ wamp \ www \ Persuasion \ admin \ edit_posts.php在線96
再次我要感謝大家誰幫助
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="admin_style.css" media="all"/>
<title>Admin Panel</title>
</head>
<body>
<div id="header">
<a href="index.php">
<h1>Welcome To Admin Panel</h1></div></a>
</div>
<div id id="sidebar">
<h2><a href="#">Logout</a></h2>
<h2><a href="view_posts.php">View Posts</a></h2>
<h2><a href="insert_post.php">Insert New Posts</a></h2>
<h2><a href="#">View Comments</a></h2>
</div>
<?php
include("includes/connect.php");
if (isset($_GET['edit'])) {
$edit_id = $_GET['edit'];
$edit_query = "select * from posts where post_id = '$edit_id'";
$run_edit = mysql_query($edit_query);
while ($edit_row = mysql_fetch_array($run_edit)) {
$post_id = $edit_row['post_id'];
$post_title = $edit_row['post_title'];
$post_author = $edit_row['post_author'];
$post_keywords = $edit_row['post_keywords'];
$post_image = $edit_row['post_image'];
$post_content = $edit_row['post_content'];
?>
<form method="post" action="edit_posts.php" enctype="multipart/form-data">
<table width="600" align="center" border="10" bgcolor="brown">
<tr>
<td align="center" bgcolor="yellow" colspan="6"><h1>Edit The Post Here</h1></td>
</tr>
<tr>
<td align="right">Post Title:</td>
<td><input type="text" name="title" size="35" value="<?php echo $post_title; ?>"></td>
</tr>
<tr>
<td align="right">Post Author:</td>
<td><input type="text" name="author" size="35" value="<?php echo $post_author; ?>"></td>
</tr>
<tr>
<td align="right" >Post Keywords:</td>
<td><input type="text" name="keywords" size="35" value="<?php echo $post_keywords; ?>"></td>
</tr>
<tr>
<td align="right">Post Image:</td>
<td>
<input type="file" name="image">
<img src = "../images/<?php echo $post_image; ?>" height="56.25" width="75"></td>
</tr>
<tr>
<td align="right" >Post Content:</td>
<td><textarea name="content" cols="30" rows="15"/><?php echo $post_content; ?></textarea></td>
</tr>
<tr>
<td align="center" colspan="6"><input type="submit" name="update" value="Update Now"/></td>
</tr>
</table>
</form>
<?php }} ?>
</body>
</html>
<?php
if (isset($_POST['update'])){
$update_id = $_GET['edit_form'];
$post_title1 = $_POST['title'];
$post_date1 = date('m-d-y');
$post_author1 = $_POST['author'];
$post_keywords1 = $_POST['keywords'];
$post_content1 = $_POST['content'];
$post_image1 = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
if ($post_title1=='' or $post_author1=='' or
$post_keywords1=='' or $post_content1=='' or
$post_image1=='') {
echo "<script>alert ('Any of the fields are empty')</script>";
exit();
}
else {
move_uploaded_file($image_tmp,"../images/$post_image1");
$update_query = "update posts set post_title='
$post_title1', post_date='$post_date1',post_author='$post_author1', post_image='$post_image1', post_keywords='$post_keywords1', post_content='$post_content1' where post_id='$update_id'";
if(mysql_query($update_query)) {
echo "<script>alert('Post has been updated')</script>";
echo "<script>window.open('view_posts.php','_self')</script>";
}
}
}
?>