这是我的PHP代码,我想问题出在$_POST[...]
?
PHP:
<?php
require('connect.php');
$name = $_POST['name'];
$comment = $_POST['comment'];
$submit = $_POST['submit'];
if($submit)
{
if($name&&$comment)
{
$query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')");
header("Location: success.php");
}
else
{
echo "Lūdzu aizpildi visus logus.";
}
}
?>
字段和文本区域的形式。
HTML:
<form action="help-add-comment.php" method="POST">
<label>Jūsu vārds: </label><br /><input type="text" name="name" size="25" value="<?php echo "$name" ?>" /><br /><br />
<label>Ziņojums: </label><br /><textarea name="comment" cols="25" rows="7"></textarea><br /><br />
<input type="submit" class="button button-red" name="submit" value="Pievienot" /><br/>
</form>
这是我的结果: