0

guys i am new to php and all what i know is html .so please tell me how to create a commenting box that allow people to comment on my website or my post .

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by sandeepji1
0

Hi

First you will have to create gui(text fields and buttons) to get that details
Like-

Person Name-
Email ID-:
Comment-:

On this form you will have buttons Save and Cancel.

On click of Save button your form(form where that save button is) should be redirected to a little php script to save that comment entry.After inserting that entry into a database that should redirected user to a HOME page or where ever you want him to go on.

These values you will have to store in a database or in a file.

You have two ways
As omol suggested
one is using mysql database.
Create table in a database
Table name-comments

Add Fields with proper datatype
name, email, comment, datetime

and second ways is write that entries in a text file or csv separated by delimiter.

If you have any doubt Please let me know.

Thanks

0

Hi, You Just Try That Code that Help You

<?php
if(isset($_POST['posted'])=='true')
{
$connect=mysql_connect('localhost','root','');
$db=mysql_select_db('dir_db',$connect);
$user_comment=$_POST['dir_usercomment'];
// Now, We Perform Saving Operation.
if(isset($_POST['dir_save']) == 'Save')
 {
$query=mysql_query("INSERT INTO dir_registration(comment)             VALUES('$user_comment')",$connect);
 }
//Now We Perform Cancel operation.
 if(isset($_POST['dir_cancel']) == 'Cancel')
   {
    exit();
   }
// Now We Perform Reset operation.
   if(isset($_POST['dir_reset']) == 'Reset')
     {
         $user_comment = ' ';

     }
}
?>
<form name="registration_dir" method="post" action="registration_dir.php">
<div align="center">
<input type="hidden" name="posted" value="true");
<input type="submit" name="dir_save" value="Save">&nbsp;
<input type="submit" name="dir_cancel" value="Cancel">&nbsp;
<input type="reset" name="dir_reset" value="Reset">
</div>
<table align="center" border="">
       <tr>
             <td><b>Address</b><br />
               <textarea  name="dir_usercomment" rows="3" cols="33">
                 !! Enter Comment Here !!
                 </textarea>
             </td>
       </tr>
       </table>
</form>

and still you have problem Then Just Mention Here.

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.