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 .

Recommended Answers

All 4 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.