Login Register






how to create coment page in html or php ??? filter_list
Author
Message
RE: how to create coment page in html or php ??? #4
main page (comment.php).
Code:
<!DOCTYPE html> <head> <title>comment</title> </head> <body> <form method='POST' action='addcomment.php'> <label for='name'>Name :</label><br/> <input type='text' id='name' name='name'> <br/><label for='comment'>Comment :</label><br/> <textarea id='comment' name='comment'> </textarea><br/> <input type='submit' value='add'> </form><br/><br/> <?php $host='localhost'; $user='root'; $pass='harddisk'; $db='comment'; $table='comment'; $connection=mysql_connect($host,$user,$pass) or die('err1'); $select_db=mysql_select_db($db) or die('err2'); $get_comments=mysql_query("SELECT * FROM $table") or die('err3'); echo '<fieldset>'; while($getcomment=mysql_fetch_row($get_comments)) { echo '<dd>Name : '.$getcomment['1'].'<dd>'; echo '<dd>Comment : '.$getcomment['2'].'<dd>'; echo '<br/>'; } echo '</fieldset>'; mysql_close($connection); ?> </body> </html>

page which will add comment in database (addcomment.php)
Code:
<?php $host='localhost'; $user='root'; $pass='harddisk'; $db='comment'; $table='comment'; $name=$_POST['name']; $comment=$_POST['comment']; $connection=mysql_connect($host,$user,$pass) or die('err1'); $select_db=mysql_select_db($db) or die('err2'); mysql_query("INSERT INTO $table (name,comment) VALUES ('$name','$comment')") or die(mysql_error()); mysql_close($connection); header('location:comment.php'); ?>

Reply





Messages In This Thread