473,480 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to code comment box with PHP and mysql

4 New Member
i am developing a comment box with php and mysql,but my problem now is how to post the comment after user has enter their comment.so far i my php and mysql that save the comment in the database,but i want it to be visible on my webpage after it is save to database,i don't know the code for that,i need help.


Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>
  5. commenting system
  6. </title>
  7. </head>
  8. <body>
  9.  
  10. <form action = "cm.php" method = "POST">
  11. <input type = "text" name = "fname" placeholder = "Name"><br><br>
  12. <input type = "text" name = "website" placeholder = "website"><br><br>
  13. <textarea type = "text" name = "scomment" rows = "6" col = "250" placeholder = "comment here....">
  14. </textarea>
  15. <button type = "submit">SUBMIT</button>
  16. </form>
  17.  
  18.  
  19. </body>
  20. </html>
cm.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include 'db.php';
  3. $fname = $_POST['fname'];
  4. $website = $_POST['website'];
  5. $scomment = $_POST['scomment'];
  6.  
  7. $sql = "INSERT INTO client (fname, website, comment) VALUES ('$fname', '$website', '$scomment')";
  8. $result = $con->query($sql);
  9.  
  10.  
  11. header("Location:index.php");
  12.  
  13. ?>
db.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $con = mysqli_connect("localhost", "root", "", "comment");
  4.  
  5. if(!$con){
  6. die("connection error".mysqli_connect_error());
  7. }
May 11 '17 #1
2 2309
Dormilich
8,658 Recognized Expert Moderator Expert
my problem now is how to post the comment after user has enter their comment.
on which page do you want to display the comments?
May 15 '17 #2
chijioke
4 New Member
now i was able to display the comment,but my problem is how to make each comment has its reply under the respective comment how can i go about this.
May 22 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1486
by: Ron James | last post by:
I've included the following in a C# class: /// <summary> /// The method <c>Junk</c> doesn't do anything. /// </summary> public void Junk(){} After running Tools->Build Comment Web pages,...
6
1408
by: Andy | last post by:
Hello Is there an option in the Code Comment Tool, so that the values of constants are automatically commented? Or must I comment them manually? Thanks - Andy
0
1081
by: charles_weaver | last post by:
I create a Code Comment Web Report for a C# ( or C++) project. All of the files are there, one for each method. But when I run the meain page it doesn't seem to hook together. I get to the page...
0
1797
by: Andreas | last post by:
Hi there! The splendid Code Comment Web Report is only available in C#. I request it in VB.net. The documentation states: "Currently, only C# supports the code comment syntax required for...
4
1841
by: Ted | last post by:
Understand, I have developed a number of applications using RDBMS, including MySQL, PostgreSQL and MS Access, but this is my first experience with MS SQL. I'd bet my bottom dollar that MS SQL...
2
1524
by: Dodong | last post by:
I have just transfered my access data to MySQL on a Windows XP platform, but I was stuck with these problems. What is the VB code to determine if a database is existing in MySQL and what is the code...
1
1469
by: ephemie | last post by:
Hi all, Not sure whether this is a javascript or MySql issue. Have below javascript code of embedded flash player stored in text field in MySql, with php reading it into a variable and echoing...
2
2763
by: abdulwajeed3804 | last post by:
I am searching the code of php and mysql i have created a employee details form like id, firstname, lastname, gender, age, qualification. I have created radio buttons to male and female and if i am...
0
7040
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6905
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6736
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6908
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2994
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.