我的处理程序中有一个表格:
<form action="../submitcomment.php" method="post">
<input maxlength=100 size=60 type="text" name="IP" value="' . $ip . '" readonly="readonly" hidden="hidden">
<input maxlength=100 size=60 type="text" name="BlogId" value="' . $blogId . '" readonly="readonly" hidden="hidden">
<input maxlength=100 size=60 type="text" name="Date" value="' . $date . '" readonly="readonly" hidden="hidden">
<input maxlength=100 size=60 type="text" name="Name" placeholder="Enter Your Name">
<input maxlength=100 size=60 type="text" name="Email" placeholder="Enter Your Email">
<input maxlength=100 size=60 type="text" name="Comment" placeholder="Enter Your Comment">
<br>
<input type="submit" name="Submit" value="Submit Your Comment">
</form>
行动是submitcomment.php
:
$ip = $_POST['IP'];
$BlogId = $_POST['BlogId'];
$Date = $_POST['Date'];
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Comment = $_POST['Comment'];
$blog = new Blogs();
if (isset($_POST['Submit']))
{
$addComment = $blog->insertComment($ip, $BlogId, $Date, $Name, $Email, $Comment);
header('Location: http://www.ryan.archi.dev.netsite.co.uk/Blog?success=1');
}else{
header('Location: http://www.ryan.archi.dev.netsite.co.uk/Blog?fail=1');
}
它引用了我班级中的一个函数:
function insertComment($ip, $BlogId, $Date, $Name, $Email, $Comment)
{
$query = "INSERT INTO BlogComments (Name, Comment, IPAddress, Email, BlogId, Date) VALUES ('$Name', '$Comment', '$ip', '$Email', '$BlogId', '$Date')";
$oDatabase = new database;
$connection = $oDatabase->Connect();
$result = mysql_query ($query, $connection);
return $result;
}
插入尝试不会返回或引发任何错误。据我所知,这应该有效,你能发现我做错了什么吗?