大家好,我在更新我的记录时遇到问题..当我单击编辑按钮时,它不会更新记录,但会为所有帖子变量提供以下错误..我非常感谢任何评论或帮助...
这是课程-edit.php
<?php include("../includes/config.php"); ?>
<?php
if ($_SESSION["isteacher"])
{
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$courseid=$_GET["id"];
$result = mysql_query("SELECT * FROM courses WHERE (id='".$courseid."')");
while($row = mysql_fetch_array($result))
{
$id=$row['id'];
$title = $row['title'];
$des = $row['description'];
$subjectid = $row['subjects-id'];
}
mysql_close($con);
?>
<script type="text/javascript">
$(function() {
$("form").validity(function() {
$("#title")
.require("This Field Must Be Filled!!")
});
});
</script>
<?php include("../includes/header.php"); ?>
<?php include("includes/nav.php"); ?>
<div id="maincontent">
<div class="span-24 last">
<div id="breadcrumbs">
<a href="index.php">Home</a> >
<a href="manage-courses.php">Manage Courses</a> >
<a href="courses-list.php">List Courses</a> >
Edit Course
</div>
</div>
<?php include("../teacher/includes/manage-courses-aside.php"); ?>
<div class="span-18 last">
<h2 class="alt">Edit Course</h2>
<form id="form" method="post" action="courses-edit-action.php">
<input type="hidden" value="<?php echo $courseid; ?>" name="id" />
<label>Course Name:</label><input type="text" name="title" id="title" class="text" value="<?php echo $title; ?>" /><br /><br />
<label>Choose Subject:</label>
<?php
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM subjects");
echo "<select name='subjects-id'>\n";
while($row = mysql_fetch_array($result))
{
echo "<option value='".$row['id'] . "'";
if ($subjectid==$row['id'])
echo 'selected="selected"';
echo " >" . $row['subjectname'] . "</option>\n";
}
echo "</select>\n";
mysql_close($con);
?>
<label>Description:</label><textarea name="description" id="description"><?php echo $des; ?></textarea><br /> <br />
<input type="submit" value="Edit Course" class="button" />
</form>
<?php include("../includes/footer.php"); ?>
<?php
}
else
{
header("Location: ".$fullpath."login/unauthorized.php");
}
?>
这是课程-编辑-action.php
<?php include("../includes/config.php");?>
<?php
$id=$_POST["id"];
$title=$_POST["title"];
$des=$_POST["description"];
$subjectid=$_POST["subjects-id"];
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("ombts", $con);
$query=("UPDATE courses SET title='".$title."', description='".$des."', 'subjects- id'='".$subjectid."' WHERE (id='".$id."')");
$query=mysql_query($query);
if($result){
echo header("Location:manage-courses.php?status=2");
}
mysql_close($con);
?>
警告是
Notice: Undefined index: id in C:\xampp\htdocs\project\teacher\courses-edit-action.php on line 4
Notice: Undefined index: title in C:\xampp\htdocs\project\teacher\courses-edit-action.php on line 5
Notice: Undefined index: description in C:\xampp\htdocs\project\teacher\courses-edit-action.php on line 6
Notice: Undefined index: subjects-id in C:\xampp\htdocs\project\teacher\courses-edit-action.php on line 7