Pls I need to create a php comment box for my site dat shows user image after dey comment and also shows guest image as avatars after dey comment on each product, like dat of dis site thanks in advance.
Hello, you'll need to set up a database with the correct amount of tables with the correct information. You are probably going to be collecting: Names Email Addresses Website Message The contact form should allow submission, sanitise inputted information, validate inputted information then store the information in the database. If the information does not pass all validation tests successfully, an error message should be shown to the user. It is fairly easy to retrieve this information from the database to display it on the page, the email address provided should also be used to search for a Gravatar, the Gravatar should be displayed if one exists, otherwise a default avatar should be displayed.
Please use the information I have provided you to do some research and learning of your own. No one is going to create this for you.
Here is the skeleton of my script for comments. I have change/cut a lot of code but this is the base. You can add fields (images, etc.). <!-- this code goes in each product page --> <?php $username = "xxx"; $password = "xxx"; $db = "xxx"; $host = "localhost"; $xdb = new PDO("mysql:host=$host;dbname=$db", $username, $password); $xdb->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); function commentlist ($productid) { $q = "select * from commenttable where productid like '" . $productid . "'"; $query = $xdb->query($q) or die("Database problem!!"); $query->setFetchMode(PDO::FETCH_ASSOC); while($row = $query->fetch()) { echo "<div class='poster'><div style='float:left'>" . $row["nickname"] . "</div><div style='float:right; font-weight:normal; font-size:10px'>" . date("F d, Y", strtotime($row["added"])) . "</div></div>"; echo "<div class='comment'>" . $row["comment"] . " </div>"; } } function countComments ($productid) { $q = "select count(id) as count from commenttable where productid like '" . $productid . "'"; $query = $xdb->query($q) or die("Database problem!!"); $query->setFetchMode(PDO::FETCH_ASSOC); while($row = $query->fetch()) { echo $row["count"]; } } ?> <div class="comment" id="comment"> <p>Comments (<?php countComments($productid); ?>)</p> <div class="comments"> <div> <form name="comfrm" action="comments.php" id="comfrm"> <textarea name="comment" id="comment" placeholder="Leave a comment..."></textarea> </div> <div style="height:50px;"> <div style="text-align:left; float:left"><input type="text" name="poster" id="poster" placeholder="Post as..." /><input name="productid" id="productid" type="hidden" value="<?php echo productID; ?>" /></div> <div style="float:right; margin-top:15px; margin-right:35px;"><input type="submit" name="submit" class="submit" id="submit" value="submit" /></div> </div> </form> </div> <div class="commentlist"> <?php commentlist($productid); ?> </div> </div> <!-- end code --> <!-- comments.php file --> <?php $username = "xxx"; $password = "xxx"; $db = "xxx"; $host = "localhost"; $xdb = new PDO("mysql:host=$host;dbname=$db", $username, $password); $xdb->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $s = $xdb->exec("insert into commenttable (nickname, added, comment, productid) values ('" . $_POST['poster'] . "',DATE_FORMAT(NOW(),'%Y-%m-%d'),'" . $_POST['comment'] . "','" . $_POST['productid'] . "')"); $xdb = NULL; ?> <!-- end file --> PHP: I hope that will be helpful to start. But if you don't want to mess with code you must find a full script for comments. google it and you will find something.
It sounds like you're a tad out of your depth here. You're either going to have to learn a language like PHP, or use something premade like Disqus.