所以我累了,已经尝试了几个小时,仍然找不到为什么它不起作用。了解我,这可能是我在某个地方犯的一些愚蠢的错误。Anyhoo,我有一个我需要能够提交的表单,然后输入的文本被插入到数据库中。但是,每当我按下提交时,它都会返回主页并且不插入任何内容。代码在这里:
//New Memory
<?php
if ($x == 'new') {
?>
<a href="pensieve_elizabeth.php"><- Back</a>
<center>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<input type="hidden" name="submitted" value="submitted" />
<p><b>Add Memory </b></p>
<p>Title:<br>
<input class="textfield" name="title" maxlength="55" style="width:325px;">
<br>
Memory: <br>
<textarea class="textfield" name="entry" value="entry" id="entry" cols="30" rows="10" style="width:325px;"></textarea><br>
<input type="submit" value=" Submit " />
<input type="checkbox" name="private" value="1"> Private
<p>What thread does the memory belong to? (optional):<textarea class="textfield" name="links" rows="1" style="width:325px;"></textarea><br />
</form>
</td>
</tr>
</table>
</center>
<?php
if(isset($_POST['submitted'])) {
$title = trim(addslashes(strip_tags(htmlspecialchars($_POST['title']))));
$entry = trim(addslashes(strip_tags(htmlspecialchars($_POST['entry']))));
$private = $_POST['private'];
$links = $_POST['links'];
if (empty($title)) message("Please give the memory a title.");
if (empty($entry)) message("Your memory is empty.");
mysql_query("INSERT INTO pensieve SET uid = '$userID', subject = '$title', memory = '$entry', dateline = '".date()."', private = '$private', links = '$links'") or die(mysql_error());
message("You have successfully submitted this memory to your pensieve!","/pensieve_elizabeth.php");
}
}
?>