Saturday, 30 July 2011

Php code for Comment on Webpage

Php code for Comment on Webpage
$Yourwebpage.php
<!-- Comment Entry Section  !-->
    <table cellpadding="0" cellspacing="0"><tr>
      <td width="25%" valign="top"><form method="post" action="<? echo $pfile;?>" name="comment">
          <table bgcolor="silver" align="center" cellpadding="5" cellspacing="0" width="270px">
            <tr>
              <th colspan="2"><? if($_POST["do_comment"]==1) {
                                        $name=$_POST["name"];
                                        $email=$_POST["email"];
                                        $website=$_POST["website"];
                                        $comment=$_POST["comment"];
                                        $page=$_POST["page"];
                                        $status=0;
                                        $page=$_post["page"];
                                        $query="insert into comment values('$name','$email','$website','$comment',$status,'$pfile')";
                                        $result=mysql_query($query);
                                        if($result!=NULL)
                                            echo "<font color='red'>Thanks for your comment ; Your comment need approval after approval it will be display on website.</font><br>";
                                    }
                                    ?>
                <? $file = $_SERVER["SCRIPT_NAME"];
                                    $break = Explode('/', $file);
                                    $pfile = $break[count($break) - 1];
                                    ?>
                Write your comment</th>
            </tr>
            <tr>
              <td>Enter Your Name</td>
              <td><input type="text" size="20" name="name" /></td>
            </tr>
            <tr>
              <td>Enter Your Email</td>
              <td><input type="text" size="20" name="email" /></td>
            </tr>
            <tr>
              <td>Enter Your Blog</td>
              <td><input type="text" size="20" name="website"  value="http://"/></td>
            <tr>
              <td colspan="2">Enter Your Comment</td>
            </tr>
            <tr>
              <td colspan="2" align="center"><textarea rows="5" cols="25" wrap="virtual" name="comment"></textarea></td>
            </tr>
            </tr>
            <tr>
              <td colspan="2" align="center"><input type="hidden" name="do_comment" value="1" />
                <input type="hidden" name="page" value="<? echo $pfile; ?>" />
                <input type="submit" value="Submit" />
                <input type="reset" value="Clear" /></td>
            </tr>
          </table>
        </form>
  
  </td>
      <td valign="top"><!-- Comments Display Section  !-->
          <div id="comment">
            <center>
              <b>Comment on <? echo $pfile; ?></b>
            </center>
            <br />
            <?
                        $query="select * from comment where page='$pfile' and status='1'";
                        $result=mysql_query($query);
                        $temp=0;
                        while ($row = mysql_fetch_array($result)) {
                            $temp=1;
                            if($row[2]==NULL || $row[2]=="http://")
                                echo "<b>",$row[0]," (",$row[1],") </b><i>Wrotes</i> <b>",$row[3]," </b><hr>";
                            else
                                echo "<a target='_blank' href='",$row[2],"'><b>",$row[0],"</a> (",$row[1],")</b><i> Wrotes </i><b>",$row[3],"</b><hr>";
                        }
                        if($temp==0)
                            echo "<i>No comment on this section</i>";

                        ?>
          </div>
   <div align="right" style="padding:5px;" ><a href="comment.php" style="color:#0000FF">View All</a></div>
</div>
</center>

    </td>
      </tr></table>
OUTPUT
 
Fig-1
Table of Enquiry
CREATE TABLE `comment` (
  `name` varchar(20) NOT NULL default '',
  `email` varchar(40) default NULL,
  `blog` varchar(40) default NULL,
  `comment` text,
  `status` tinyint(1) default '0',
  `page` varchar(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Comment will be Display on web page when status will be 1. So create admin section to change or alter the Data of comment posted by the user or you can store 1 when you don't need of authorization required.
 
"Php code for Comment on Webpage" Php code is made for Distribution purpose;
Modify it as per your requirement.

style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-5656072117057856"
data-ad-slot="8835885279">



SHARE YOUR ARTICLE

If you have any article, photograph, video etc which you want to share with us through our blog. You can send email us at talkduo@gmail.com or click here

10 comments:

  1. bookmarked!!, I really like your website! Payday Loans
    Feel free to visit my blog - payday loans

    ReplyDelete
  2. Good post. I learn something totally new and challenging on sites I stumbleupon everyday.
    It's always helpful to read through articles from other writers and practice something from their websites. raspberry ketone cla
    Here is my webpage raspberry ketones

    ReplyDelete
  3. I could not resist commenting. Very well written! http://www.myquickloans.co.uk
    Feel free to surf my weblog ... instant cash

    ReplyDelete
  4. Spot on with this write-up, I really think this website needs a lot more attention.

    I’ll probably be back again to read more, thanks for the info!
    payday loans
    Stop by my blog :: link

    ReplyDelete
  5. Right here is the right site for everyone who would like to understand this topic.
    You understand a whole lot its almost hard to argue with you (not that I really will need
    to…HaHa). You certainly put a fresh spin on a subject which has been written about for decades.
    Excellent stuff, just wonderful! link
    Also visit my web-site :: here

    ReplyDelete
  6. Your style is really unique compared to other people I have read stuff from.

    Many thanks for posting when you've got the opportunity, Guess I'll just bookmark this blog. free bets
    Also visit my website ... thefreebet.co.uk

    ReplyDelete
  7. I blog often and I truly thank you for your information.
    Your article has truly peaked my interest. I will take a note of your website and
    keep checking for new details about once per week. I subscribed to your Feed as well.

    payday loans
    Have a look at my web-site :: next page

    ReplyDelete
  8. You are so interesting! I do not suppose I've read something like this before. So wonderful to find another person with some original thoughts on this issue. Really.. thanks for starting this up. This site is something that is needed on the internet, someone with some originality! more info
    Here is my web blog ... raspberry ketone

    ReplyDelete
  9. I need to to thank you for this fantastic read!
    ! I certainly enjoyed every little bit of it. I have got you book-marked to look
    at new things you post… pay day loans uk
    Here is my web-site :: payday loan uk

    ReplyDelete