-1
我試圖顯示一些信息存儲在MySQL評論表輸入,但我有問題。輸入名爲enterComment
將數據插入到我的數據庫中,並且我希望它重新導向回到showComment
輸入。顯示來自數據庫的記錄
HTML:
form action='takedata.php' method='POST'>
<input type='text' id='enterComment' name='enterComment' width='400px' placeholder='Write a comment...'>
<input type='submit' id='combuton' name='comButon' value='Comment!'>
<input type='text' id='showComment' name='showComment'>
</form>
PHP:
<?php include "mysql.php"; ?>
<?php
if (isset($_POST['comButon'])){
$enterComment = strip_tags($_POST['enterComment']);
if($enterComment){
$addComment = mysql_query("INSERT INTO comments(comment) VALUES('$enterComment')");
if($addComment==1)
//INSERT INTO showComment input;
}
}
?>
你的VIEW的代碼在哪裏? – Hassaan
請閱讀關於如何使用PDO或mysqli與數據庫建立連接的文章。 –