这是表单处理
if(isset($_POST['clear'])) {
mysql_query("DELETE FROM md5dictionary");
}
if(isset($_POST['submit'])) {
if(strlen($_POST['keywords']) < 1 || ctype_space($_POST['keywords']) == true) {
$errors['blank'] = "<span class='error'> Please insert a word </span>";
} else {
$newword = $_POST['keywords'];
$db_checkExist = mysql_query('SELECT * FROM md5dictionary WHERE keywords="' . $newword . '"');
echo mysql_num_rows($db_checkExist) . "<br />";
if(mysql_num_rows($db_checkExist) > 0) {
echo "outside else " . mysql_num_rows($db_checkExist);
$finalResult = "<span class='error'> Failed!!! </span>";
} else {
echo "inside else " . mysql_num_rows($db_checkExist);
$md51 = md5($newword);
$md52 = md5($md51);
mysql_query('INSERT INTO md5dictionary(keywords, mdFive, mdFive2) VALUES ("' . $newword . '", "' . $md51 . '", "' . $md52 . '")');
$finalResult = "<span class='success'> Thank you! Wanna add another one? </span>";
}
}
}
这是表格
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<fieldset> Input Form </fieldset>
<label for="keywords"> Input new Keywords into dictionary: </label>
<?php echo $finalResult; ?>
<?php echo $errors['blank']; ?>
<input name="keywords" type="text" />
<input name="submit" type="submit" value="Add!!" />
<input name="clear" type="submit" value="Clear Database" />
</form>
<h1> Datas: </h1>
<?php
$result = mysql_query("SELECT * FROM md5dictionary");
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; ++$i) {
echo "Data " . $i . "<br />";
echo "keywords: " . mysql_result($result, $i, "keywords") . "<br />";
echo "md5: " . mysql_result($result, $i, "mdFive") . "<br />";
echo "md5_2: " . mysql_result($result, $i, "mdFive2") . "<br />";
}
?>
结果如下:http: //md5dictionary.hoangminhdat.com
问题:为什么它一直说“失败!” 为什么它已成功地将信息插入到我的数据库中?应该没有拼写错误
我知道解决我的愚蠢问题会很耗时,但请,我自己无法解释!