出于某种原因,此查询仅在表内没有具有相同reply_id 的行时才会提交。
编辑:我怎么做才能继续输入数据?它与重复键有关吗?代码:
if (isset($_POST['submit'])) {
$blah = $_POST['id'];
$errors = array();
if (isset($_POST['comment'])) {
if (empty($_POST['comment'])) {
$errors[] = 'Error, try again!';
}
if (strlen($_POST['comment']) > 400) {
$errors[] = 'Comment must be in a 10 to 400 characters range!';
}
if (empty($errors)) {
$q2 = mysqli_query($link, "INSERT INTO reply VALUES($blah, _comment, now(), '$id')");
header("Location: topic.php?id=$blah");
} else {
echo 'You have ' . (count($errors) + 1) . ' errors in your form:<br />';
foreach ($errors as $error) {
echo $error . '<br />';
}
echo '<a href="new_topic.php">Try again</a>';
}
}
形式:
<form action="topic.php" method="POST">
<textarea name="comment" class="field span6" rows="3"
placeholder="Content..."></textarea><br/><br/>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<div><input type="submit" name="submit" placeholder="Reply"/></div>
</form>