In this tutorial, we’re showing you how to setup a HTML form that allows a user to enter comments. We will achieve this by interacting with a MySQL Database using PHP on cPanel Hosting. We’re creating a simple 2 page website that allows users to post comments on either page, and then shows all comments that have been posted.
Be sure to check out our previous article where we created a database and setup a table to hold those comments.
A Quick Introduction to HTML Forms
Gathering the Form Data
An HTML form allows a user to type data into a website, and then it submits the data to another page for processing. For example, if you fill out a comment on a website and hit submit, everything that you typed in is submitted to a script on the server that writes your comment to a database.
HTML forms can handle quite a few different forms of input. For example, they can handle:
Text Boxes:
Radio Buttons
Option 1
Option 2
Checkboxes
Selection 1
Selection 2
… and more!
Submitting the Form Data
After the user has filled in the above data and clicks a submit button, it will send all of their data to another script for processing. It can either send the data back to the same page for processing, or it can send it to a completely different script to handle the processing.
When the data is passed to a script for processing, it can be passed using either GET or POST. When using GET, all the data is passed in the url, such as: GETdomain.com/page.php?name=brad&[email protected]
As you can see, my name and email address is passed in the URL. If you use POST (instead of get), the URL will simple read:
POSTdomain.com/page.php
… and my name and email address will be passed behind the scenes.
Our Example Contact Form
Because our comments form is going to be relatively simple, we will be using text boxes for most of the input. Below is our contact form and what the contact form will look like:
For getting customers to the feedback contact form is very important for us you explain in detail thankyou very much for sharing such a useful piece of information keep sharing and update us.
This is the exact information I was looking over the internet. Thanks you for this great help. You have shared really very nice articles. I like your website as well. Thanks for everything.
Thanks for telling us. We can update the article later to show the code. In the meantime, you can use your browse “view page source” or “inspect element” features to see the raw code for the PHP page.
Thanks for sharing this. I’ve been trying to learn a little PHP. Great post for me and people who already use other languages like asp or asp.net and want to explore PHP. This is very helpful. Keep on the great work. I just want to say that there is no need to dive too deep in PHP if you don’t want to. A versatile coder can just pick what they need for a particular scenario.
I was wondering how i would change the size of the comments section when using this code. Is there any way to make it all one size without messing up the code?
We are glad you found this helpful! Thanks for your feedback. Be sure to click the Yes button next to: “Did you find this article helpful?” This helps others in the community quickly locate the most helpful articles!
Thanks for the tutorial for lots of usabilities and customize features. It is very much crucial for a beginner who is interested in design because every step is meaningful and easy to understand and it is also user-friendly. You have explained very well about how can design creative design. Mostly I like this.
Sorry for the issues with your website testimonials. It appears that either you have been hacked or there s a spammer adding the unwanted entries on your site. You can use our guide on Recovering from a hack to help guide you or you can try to work with our live technical support team.
If you have any further questions or comments, please let us know.
Hi there, I’ve been trying to create a form that would send the data entries into my database; however, I always get the error “invalid article id”. And the url’s of my pages look like this:
and so on. So the problem is the urls do not contain the id which is supposed to be something like “?id=1”. And because of that it gives the error. How can I fix this problem?
Thank you for posting your comment. I’m sorry to see you’re experiencing issues with the articleid in your form. The articleid is detected by the link you are posting the comment on, it is not read from the database (contrary to previous posts). So if you are using the following links:
then you will continue to see errors regarding the articleid (because the link does not specify the articleid). To resolve this, you would need to configure your links to be formatted like so:
I set up the database as described in the tutorial, with the articleid having a value of 1. When I check the DB values, it is 1. So you are saying that when opening the page, it checks the DB and returns that value and places it in the URL?
In the tutorial, which code does this? Or is it a function of php to always do this if the DB has an articleid value?
Yes, PHP uses the GET method to get information about what to display from the database. This is explained in more detail above in the “Submitting the Form Data” section.
I have tried everything I can think of to enter the code to get the id=1 recognized. No matter what I do, my page when viewed in the browser does not show the page name with the extension “.php?id=1” and when I try to submit a comment, I get “invalid article id.”
What code should I put on my page? and where should I put it (doctype? head? body? html?)?
I’m sorry to see you’re having difficulty in assigning the article id. The “article id” appears to be a value that’s in the database. If you look at the earlier articles in this series you will see how it was added to the database. I hope this helps to answer your question, please let us know if you require any further assistance.
Hi i have a comment box on my website where people write testmonials about my business, unfortunatly someone has put pages and pages of computer jargon advertising their business on it – how do i remove it
Your comment box is typically getting data through a database. You can use a query to remove the entries, you can physically go through and remove them, load a clean version, or you can find a tool to do this for you.
If you have any further questions, please let us know.
thanks alot for this tutorial…but i keep getting “invalid articleid” am running this example using a local server and i don’t have any idea on how to give the pages an id…please help
The “articleID” appears to be a value that’s in the database. If you look at the earlier articles in this series you will see how it was added in the database. I hope this helps to answer your question, please let us know if you require any further assistance.
I wanted to Create a simple html page backed by php which simply asks you a website address and php uses alexa api to return its rank. can some body help me ? Many Thnaks in advance!
I would start with the Alexa API documentation. Since its a paid service, you will need to review the requirements there first. https://aws.amazon.com/awis/
Hi there, thank you for the article and the comment box script. You have mentioned that it is possible to style comment box in either html or css. Could you elaborate on that as I was trying to move elements of the fields by using their ids and nothing works.
Thanks for the question about styling comment boxes in either HTML or CSS. We do not provide direct coding support (except with the code provided in our articles). However, we can point out resources that have the possible solution for you. Check out these two articles:
Tables and Divs are two separate tags used for different things. Unfortunately, without knowing what you want to accomplish, I can’t tell you which one is more practical. DIVs are containers. Tables are used to structure data.
use (placeholder=”Type Here”) instead of (value=”Type Here”) for a text box like at the begining of the article. It makes the text lighter and prevents anyone about to type from needing to delete the text written in the (value) attribute. Just trying to help anyone I can.
To keep our example straight forward, the form above does not include much formatting. In a real life scenario, you could use css and other html to elements to make the comment form a bit more user friendly.
Thanks for the question about Hadoop. This is not a good forum for finding specific programming information about Hadoop as programming support is beyond our scope of support. You may want to check out forums such as this one in order to find out more information concerning programming with Apache Hadoop.
If you have any further questions or comments, please let us know.
You have to use PHP in order to connect to a database as HTML can not do it natively. We have an article on using PHP to insert data into databases which may help in your situation.
Yes that clarifies things.I recall mentioning in the ‘op’ that I usually test and mess around with things locally then, once satisfied, upload to the server.
The trouble I previously mentioned was in fact ON the Server. Attempting to connect using “localhost” was and is not working. Only when replacing it with “…..mysqlipage.com” do I achieve a connection. I’m a little concerned but as you said unless the database is ‘Open’ to anyone’ (it’s not) things should be ok. Additionally, I think that using “…mysqlipage.com” is going through a secure layer or something to that effect.
Anyway guy’s, Thank you very much for the help! I’m going to have to put you at the top of list of hosting providers when it comes time to start shopping again!
After checking further it was in fact how page1 was calling the server IE; ‘localhost’. I actually entered the address to the db and got my “Thank you for your comment” response however…I’m not so sure that I’m ok with the address being there in the ‘manage…’ php. Could this be a security risk?
The database should definitely be set as “localhost” if you are hosted with us. If the website code is being run to access the server from the website, then code is “local” to the database and that is the correct setting. If your code is running outside of the database, then it will need to have access through some form. I agree with you in that if the code is using an IP address, that is not very secure – but only if it’s not server-side, and only if access to the server is general – meaning anyone can access it without an authorized user. It should be set up so that only an authorized user would be accessing the database without having to give just anyone access to the database. Typically, if the code is running server-side, then outside viewers would never see that transaction between the function and the db.
I hope this helps to clarify the issue. If you have any further questions or comments, please let us know.
Hey Scott, You’re very welcome! I’m a Code ADDICT! Problem is, I’m so into learning, I have trouble staying with ONE language long enough to get all of it before I’m off again grabbing an IDE and starting in on another language!
Anyway. Yes The ‘< ? include… ?> method works great. Ive started implementing into other projects. Concerning the creation of comments that is the focus of this tutorial, once I had the php in place I open page one and was greeted with the error that essentially came down to the server ‘burping’ at the request. It’s been a day or so since I’ve messed with this so I’ll have to recreate the error and get back to you but from what I can recall it’s something to do with the socket? possibly address of the server or something to that effect. I’m on my way to get the details now..I’ll post them shortly!
Keep up the fantastic spirit of sharing guy’s. One of the number one things I always loved about the open source community or organizations such as yours was the desire to share what we know. Sometimes the teachers become students and Students become the teachers. Love it!
Now I’m no ‘Wiz’ at this (exactly why I’m looking to you for the tutorial) but I’ve
hit a wall while performing the steps in the ‘include’ tutorial.
Note: I’m following along using PHPDevServer on my Laptop as it’s a little quicker
by saving me the setup process of opening an ftp program, connecting to my site, uploading,downloading etc. Point here is this could in fact be the program and nothing to do with the given information or my syntax.
After injecting the form markup into formcode.php, and the <? include (‘formcode.php’); ?> into pages 1 and 2, I get nothing viewable when opening pages 1 and 2 except the heading I previously inserted.
Now you did not direct us to do this, but out of curiosity I opened formcode.php directly and got the following error:
Parse error: syntax error, unexpected ‘<‘ in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\TESTING\WEBSITE13\formcode.php on line 2
It’s refering to the first line of code <form method…
This might be silly of me to say but with php aren’t you suppose to ‘echo’ or ‘print’ the html markup? Anyway, I was pretty excited about this because I learned about the “include” method of duplication and that’s going to save me from writing and REwriting my pages as I have not yet dug into Ajax and am still writing my pages the old school way!
If you create a php page, as long as the HTML is not within the <?php and ?> tags, it does not have (in fact can’t) be echoed out. The fact that the formcode as such: <? include (‘formcode.php’); ?> does indeed surround it in the tags, so you are correct, the HTML should be echoed out.
That was indeed an oversight in the development of this guide and oddly enough you are the first one to mention it. It could use some refreshing anyway so I will add that to my ‘to do’ list.
In what context are you trying to grab the URL? I”m having trouble understanding your question. Can you provide us more information on what you are trying to do?
The way you have the code will cause an email application to open on the visitor’s side with the content of the form in it. From there, they will send the email to you.
If you wish to have the form take the content and send it to your email from the server, then it needs to be passed to a php file that will process and create the mail on the server side.
We currently do not have an article for that format, but it does follow the same principles. We are happy to assist with individual questions as you work towards that. This may be a project we take on in the future, however.
I have a question how do you make a comment that everyone could see, like youtube, tier are comments on youtube that every one could see, and how do you make a reply button.
I have a question how do you make a comment that everyone could see, like youtube, tier are comments on youtube that every one could see, and how do you make a reply button.
That would require additional coding. We do not have any readymade scripts on hand for that type of thing at this point. You may want to see if you can find a freelancer to add the additional functionality to your site.
Can anyone please send me the detail code to create and to display the comment box on my website and to get notification that the user had commented on my website please.
Thanks for the question. Unfortunately, we cannot provide you code beyond what has been provided in these tutorials. If you put some of these together, you will get most of what you need. If you require other information, then you may want consult with a programmer or look at other educational sites on using PHP.
I hope that helps to answer your question! If you require further assistance, please let us know!
Could anyone assist me? I’ve set up a mail form in Dreamweaver using PHP. But, when a user fills out the form how do I set it up, so they get a copy of their message? Or even a generated automatic reply from me saying “Thank you for your message, someone will get back to you shortly”
Thank you for contacting us. You must code/develop a solution with PHP. The above example is part of a full series, where we explain how to accomplish this.
thanks for sharing this blog with us. your content is top of the funnel. always great to receive such brilliant information about such an interesting topic.you have done a great job on this blog.I am impressed with your work.
Really a great tips for beginners.I think they will be youlike it and follow you and your website.Please carry on.You should post some more article like it.
Unfortunately we do not provide custom coded solutions here in the Support Center. A comment section such as the one here entails coding much like the one above along with a database and the code for members to log in. You may be able to locate tutorials for each specific step along the way by using your favorite search engine. Other people simply hire a developer to create the functionality for them.
I would like to buy something like that but I would not want a monthly subscription just a 1 time payment, would you guys be able to make something like that ?
We do not have any specific code for something like that, but you that is certainly something that can be custom coded. Instead of using IP addresses, most would simply add some kind of membership feature with specific permissions.
Thanks a lot for the tutorial.
I build the form, but didn’t get how to manage so that when someone hits the submit, his/her comment be forwarded to my email address.
Could you please guide me.
Please give all of the codes. I am beginner and liked this comment box very much but I didn’t understand all. Is there anybody who can tell the codes that I must write on html? All steps…
We currently do not have an article for that format, but it does follow the same principles. We are happy to assist with individual questions as you work towards that. This may be a project we take on in the future, however.
I see CREATE statements, which creates tables for the database, but there is not a SELECT statement in the code. SELECT is the type of statement needed to get data out of the database.
This article is part of a series, so this particular piece does not create a fully functioning form alone. Have you also followed the other articles in the series? If so, where are you stuck? We are glad to help.
It is really a nice and helpful piece of information. I’m happy that you shared this useful info with us. Please keep us informed like this. Thanks for sharing.
I have read the comments and contribution of the members of this group and i believe that the answer to problem is here. I’m designing a forum but im having a problem opening a specific category generated from a database in another page if the user clicks on it.
In brief i want a situation when a user clicks on a category from the home page, it will take you to that category page with all the topic under the category.
I’m using PHP html for the design. please help me.
Basically, when clicking the category link, the php will need to pass the category ID on to the next page. That page will then pull the information from the database based on that category ID. We would be happy to help with any specific questions you have if you are getting stuck in implementing this.
Why do I get invalid article id error.I have a single php page and I want to receive comments one it but I am new on this and I made everything from the tutorials but still nothing ok.please help
We would need to see your page and know the steps you are taking to get the error. If you can provide that we will be happy to see if we can find the error for you.
what i want to know is this when i click on submit which email does it go how do i put in my email to submit insuch a way that when it send i see it .how does the comment show on my webpage
This particular series does not deal with email responses. It is for putting comment data into a database. We do have an article on using php for a comment form. This may help you accomplish what you asked.
Hello guys! I started coding this website similar to facebook. I had an html corse on w3school, it was helpfull. The question I want to ask is, while I was designing users profile I wanted to add a “what’s up box” that will post both photos and videos. I KNOW THE CODE IS VERY LONG AND WILL TAKE MULTIPLE SEPARATED HTM DOCUMENTS BUT PLEASE ATLEAST ATTACH IT FOR ME ON MY E-MAIL ADDRESS WITH FULL DESCRIBTION! Please!!!
Unfortunately, we would not be able to provide the full code for something like this as we do not provide full development services here, only examples that you may use to put together things on your site. There are, however, systems that are made already to generate social media sites, such as BuddyPress for WordPress, but will still take some development skills to create a fully functional site.
We do not provide custom coding requests, but do try and answer questions you may have. Also, as this is not the topic of the article, please ask a new question here so either we or another community member may be able to better assist.
I need to know I have created a form in html with php, when sumeone submit. Their data how can I view that, if they submit their data can I get that via my email. How to code for that? If you know any similar ways plz help me
My apologies, but I may have left off a tutorial that you can use to accomplish your PHPform. We have a tutorial called Using PHPMailer to send email. This tutorial provides the code and may meet your needs. The PHPmail form basically allows you to create a form that will return to you based on what you have requested with in the form. The data would be returned in email.
I hope this is an easier solution and provides the information that you require. Please let us know if you have any further questions.
Within this article, there is a link to the bottom in which it will take you to the next article in the series and eventually ends up at how to grab the comments from the database.
I recommend continuing with this series for a full tutorial on implementing a commenting system.
Thank you for contacting us. Following the above guide will allow people to fill out a page, and it will send the information to your email. Just be sure to update the email information as suggested above.
Also, let us know if you are using a CMS such as WordPress, Joomla, Drupal, or Concrete5. We can then give you an option specific to your software.
If you have any further questions, feel free to post them below.
You can use the same information to create a registration form. Do remember that each page will need to check to see if the visitor is logged on so it will know what information to display.
I might have missed something… its getting really late and ive been staring at code too much for some that doesn’t know what they’re doing.
My contact form keeps sending two emails every submission and the context of it is.
Message from Address: Phone: Email: Fax: fax Red Maple Acer: Chinese Pistache: Raywood Ash:
With no date being received from the form. Any advice is appreciated. I copied the codes from this support site and use it in conjuction with a dreamweaver php page…
This particular article has no code related to sending an email. If you can link to the article where you got our code for the email processing we may be able to take a look and see if there is a mistake where it sends two emails.
I have used the code provided and have this parse error: syntax error, unexpected ‘)’ in C/xampp/htdocs/testnew/magae_comments.php on line 18. Is there something I did not do well? Please help me. Thank you.
Without seeing your exact code, I cannot tell you exactly what to change. However, check all your parentheses to ensure they are in pairs, for ever ( you must have a ). If you have an odd number, then you will experience an error like this.
Thank so much for your kind reply. I did followed the lessons 2-6 through to the final stage , but yet comment from the pages does not register in database and does not show on the pages. Instead I got this Notice: Undefined index: comment in C:/xampp/htdocs/testnew/manage_comments.php on line 16 How do I get this resolve? Please help.
i want a code that when i click a submit button it should be submitted and i should get a another comment box to post oyhers also with reply like your comment box.
What you are describing would need a significant amount of code within both the comment box, as well as the way the page is displayed in which we unfortunately cannot develop this entire solution for you.
One known commenting system is Disqus which will handle all of your commenting code for you. Outside of this, you may want to speak to a developer to have it custom coded for you.
i can’t manage to connect my website to mysq. i install wamp software and created a database that i want to connect to my website but i can’t able to connect it help me
What did you want to validate your username and password sections against, just that they were filled in? You might have better luck with simply using HTML5 form validation that is now available. For instance you could just use the required option like this:
I have followed your tutorials deligently and implemented all the steps, but got stock when comments from my example pages where not recorded at the database. every other thing works well. How do i get comment register at the database?
Thanks for the question. This kind of thing can be done many different ways depending on the code that you’re using. We can’t always provide you the specific code, but hopefully, this link provides a PHP solution that meets your needs. You can find a tutorial on passing post data here.
We currently do not have general code samples for creating a comment section. This type of feature is usually included as part of the Content Management System such as WordPress, Joomla, Drupal, etc. Creating a comment feature would take much more coding and database interaction. You may want to check and see if there is such a feature for your program. Also, if it uses modules and plugins, there may be one for comments.
Get web hosting that grows with your business. Our all-in-one hosting platform gives you everything your website needs to scale - so you can focus on the next big thing for you and your business.
Amazing knowledge and I like to share this kind of information. Thank You so Much For Sharing This information.
Glad to hear that you found it helpful!
Your post is very good, we got to learn a lot by reading it, I hope you will keep sharing the post further. … Thank you.
For getting customers to the feedback contact form is very important for us you explain in detail thankyou very much for sharing such a useful piece of information keep sharing and update us.
Nice article and thank you for this valuable information
This is the exact information I was looking over the internet. Thanks you for this great help. You have shared really very nice articles. I like your website as well. Thanks for everything.
I didn’t see any tutorial I only saw finished work examples..
No procedure was even given
Thanks for telling us. We can update the article later to show the code. In the meantime, you can use your browse “view page source” or “inspect element” features to see the raw code for the PHP page.
hi , I want to fetch comments in same page not all pages of my website …thanks
Hello and thanks for contacting us. You can probably do this with plugins such as Simple Yearly Archive and Display Posts.
Thanks for sharing this. I’ve been trying to learn a little PHP. Great post for me and people who already use other languages like asp or asp.net and want to explore PHP. This is very helpful. Keep on the great work. I just want to say that there is no need to dive too deep in PHP if you don’t want to. A versatile coder can just pick what they need for a particular scenario.
You’re welcome Jerry. Thanks for your feedback! We are glad that this article was helpful to you.
I was wondering how i would change the size of the comments section when using this code. Is there any way to make it all one size without messing up the code?
You can use inline formatting to change your text. Check out this post for more information.
I’m trying to test this form, but it’s not working for me.
I’m sorry to see you’re having trouble with this contact form’s code. What is the error you are receiving?
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
You’re welcome and thank you for your kind words!
Very helpful
We are glad you found this helpful! Thanks for your feedback. Be sure to click the Yes button next to: “Did you find this article helpful?” This helps others in the community quickly locate the most helpful articles!
Thanks for the tutorial for lots of usabilities and customize features. It is very much crucial for a beginner who is interested in design because every step is meaningful and easy to understand and it is also user-friendly. You have explained very well about how can design creative design. Mostly I like this.
We are glad to help!
Thank you,
John-Paul
Great stuff. Dyou know how to create a comment box like ig?pics and people can comment under the pics?thanks
Glad you liked it and it helped!
Hello,
Sorry for the issues with your website testimonials. It appears that either you have been hacked or there s a spammer adding the unwanted entries on your site. You can use our guide on Recovering from a hack to help guide you or you can try to work with our live technical support team.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
thanks
Great!! This is a really informative tutorial about to create a user comment. It is massively tutorial. It saved lot of time.
Thanks.
Awesome tutorial
Hi there, I’ve been trying to create a form that would send the data entries into my database; however, I always get the error “invalid article id”. And the url’s of my pages look like this:
https://localhost/internal_assessment/main.php?mypage=page1.php
https://localhost/internal_assessment/main.php?mypage=page2.php
and so on. So the problem is the urls do not contain the id which is supposed to be something like “?id=1”. And because of that it gives the error. How can I fix this problem?
Thanks.
Hi!
Thank you for posting your comment. I’m sorry to see you’re experiencing issues with the articleid in your form. The articleid is detected by the link you are posting the comment on, it is not read from the database (contrary to previous posts). So if you are using the following links:
https://localhost/internal_assessment/main.php?mypage=page1.php
https://localhost/internal_assessment/main.php?mypage=page2.php
then you will continue to see errors regarding the articleid (because the link does not specify the articleid). To resolve this, you would need to configure your links to be formatted like so:
https://localhost/internal_assessment/main.php?mypage=page1.php?id=1
https://localhost/internal_assessment/main.php?mypage=page2.php?id=2
If the URL does not contain the “?id=#” portion, you will continue to experience errors. I hope this helps!
Sincerely,
Carlos E
I set up the database as described in the tutorial, with the articleid having a value of 1. When I check the DB values, it is 1. So you are saying that when opening the page, it checks the DB and returns that value and places it in the URL?
In the tutorial, which code does this? Or is it a function of php to always do this if the DB has an articleid value?
Thanks,
Yes, PHP uses the GET method to get information about what to display from the database. This is explained in more detail above in the “Submitting the Form Data” section.
I have tried everything I can think of to enter the code to get the id=1 recognized. No matter what I do, my page when viewed in the browser does not show the page name with the extension “.php?id=1” and when I try to submit a comment, I get “invalid article id.”
What code should I put on my page? and where should I put it (doctype? head? body? html?)?
Hi!
I’m sorry to see you’re having difficulty in assigning the article id. The “article id” appears to be a value that’s in the database. If you look at the earlier articles in this series you will see how it was added to the database. I hope this helps to answer your question, please let us know if you require any further assistance.
Sincerely,
Carlos E
thank you
Hi i have a comment box on my website where people write testmonials about my business, unfortunatly someone has put pages and pages of computer jargon advertising their business on it – how do i remove it
Hello Cathryn,
Your comment box is typically getting data through a database. You can use a query to remove the entries, you can physically go through and remove them, load a clean version, or you can find a tool to do this for you.
If you have any further questions, please let us know.
Kindest regards,
Arnel C.
Very nicely explained!!
nice work
thanks alot for this tutorial…but i keep getting “invalid articleid” am running this example using a local server and i don’t have any idea on how to give the pages an id…please help
Hello TonyRex,
The “articleID” appears to be a value that’s in the database. If you look at the earlier articles in this series you will see how it was added in the database. I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Ayoub, vous êtes très bienvenue.
Toni, we’re always glad to be of assistance! Have a great day!
I wanted to Create a simple html page backed by php which simply asks you a website address and php uses alexa api to return its rank.
can some body help me ?
Many Thnaks in advance!
I would start with the Alexa API documentation. Since its a paid service, you will need to review the requirements there first. https://aws.amazon.com/awis/
Well I know, all you have to make two pages to make it for the comments section to work. 🙂
Hi there, thank you for the article and the comment box script. You have mentioned that it is possible to style comment box in either html or css. Could you elaborate on that as I was trying to move elements of the fields by using their ids and nothing works.
Would appreciate your answer.
Kind Regards,
Maks
Hello Max,
Thanks for the question about styling comment boxes in either HTML or CSS. We do not provide direct coding support (except with the code provided in our articles). However, we can point out resources that have the possible solution for you. Check out these two articles:
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
thanks
A great tips for beginners.Thank you sharing your knowledge.
Wow Very Nice! Thank you so much for sharing great post.
can imake the comments show on my website…?????
Hello,
Thank you for contacting us. That is not covered in this tutorial series, but it sounds like you are looking for something similar to a guestbook.
I found a post via online search, where they provide a possible solution.
Thank you,
John-Paul
Nice, thanks for the tips 😀
They are the same file, page1.php. You would place it in your account as you would any other file.
hy,I m a BLOGGER
i used a heml Comment BOX but i have to put it with every post,
But now i want to get rid of it,
Is there any method to add a Code to Template so that automatically a comment box appears with the post
Plz help me.
~Wqas
What blogging software are you using?
Hi,
It’s such nice information regarding HTML coding. Can you please tell me, which one is best tag for any website DIV tag or Tables tag?.
I am little bit confused to select both of one.
Tables and Divs are two separate tags used for different things. Unfortunately, without knowing what you want to accomplish, I can’t tell you which one is more practical. DIVs are containers. Tables are used to structure data.
thankx for your code
use (placeholder=”Type Here”) instead of (value=”Type Here”) for a text box like at the begining of the article. It makes the text lighter and prevents anyone about to type from needing to delete the text written in the (value) attribute. Just trying to help anyone I can.
To keep our example straight forward, the form above does not include much formatting. In a real life scenario, you could use css and other html to elements to make the comment form a bit more user friendly.
hi,
Can anybody help in fetching the website comments in hadoop.
thanks in advance.
regards,
suma.
Hello Suma,
Thanks for the question about Hadoop. This is not a good forum for finding specific programming information about Hadoop as programming support is beyond our scope of support. You may want to check out forums such as this one in order to find out more information concerning programming with Apache Hadoop.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
How to link html page with mysql
Hello Shuhbam,
You have to use PHP in order to connect to a database as HTML can not do it natively. We have an article on using PHP to insert data into databases which may help in your situation.
Best Regards,
TJ Edens
Great article !!
Thank You Arn!
Yes that clarifies things.I recall mentioning in the ‘op’ that I usually test and mess around with things locally then, once satisfied, upload to the server.
The trouble I previously mentioned was in fact ON the Server. Attempting to connect using “localhost” was and is not working. Only when replacing it with “…..mysqlipage.com” do I achieve a connection. I’m a little concerned but as you said unless the database is ‘Open’ to anyone’ (it’s not) things should be ok. Additionally, I think that using “…mysqlipage.com” is going through a secure layer or something to that effect.
Anyway guy’s, Thank you very much for the help! I’m going to have to put you at the top of list of hosting providers when it comes time to start shopping again!
TC Scott
UPDATE:
After checking further it was in fact how page1 was calling the server IE; ‘localhost’. I actually entered the address to the db and got my “Thank you for your comment” response however…I’m not so sure that I’m ok with the address being there in the ‘manage…’ php. Could this be a security risk?
Hello Scott R,
The database should definitely be set as “localhost” if you are hosted with us. If the website code is being run to access the server from the website, then code is “local” to the database and that is the correct setting. If your code is running outside of the database, then it will need to have access through some form. I agree with you in that if the code is using an IP address, that is not very secure – but only if it’s not server-side, and only if access to the server is general – meaning anyone can access it without an authorized user. It should be set up so that only an authorized user would be accessing the database without having to give just anyone access to the database. Typically, if the code is running server-side, then outside viewers would never see that transaction between the function and the db.
I hope this helps to clarify the issue. If you have any further questions or comments, please let us know.
Regards,
Arnel C.
Ok here it is!
This is the Error I’m getting when directly calling page 1. If you like, check it yourself.
https://www.*******babiez.com/page1.php?id=1
It looks to be a simple fix but as for where to look other than the database, I’m lost.
ERROR:
Could not connect: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
Hey Scott, You’re very welcome! I’m a Code ADDICT! Problem is, I’m so into learning, I have trouble staying with ONE language long enough to get all of it before I’m off again grabbing an IDE and starting in on another language!
Anyway. Yes The ‘< ? include… ?> method works great. Ive started implementing into other projects. Concerning the creation of comments that is the focus of this tutorial, once I had the php in place I open page one and was greeted with the error that essentially came down to the server ‘burping’ at the request. It’s been a day or so since I’ve messed with this so I’ll have to recreate the error and get back to you but from what I can recall it’s something to do with the socket? possibly address of the server or something to that effect. I’m on my way to get the details now..I’ll post them shortly!
Keep up the fantastic spirit of sharing guy’s. One of the number one things I always loved about the open source community or organizations such as yours was the desire to share what we know. Sometimes the teachers become students and Students become the teachers. Love it!
Hi guy’s
Now I’m no ‘Wiz’ at this (exactly why I’m looking to you for the tutorial) but I’ve
hit a wall while performing the steps in the ‘include’ tutorial.
Note: I’m following along using PHPDevServer on my Laptop as it’s a little quicker
by saving me the setup process of opening an ftp program, connecting to my site, uploading,downloading etc. Point here is this could in fact be the program and nothing to do with the given information or my syntax.
After injecting the form markup into formcode.php, and the <? include (‘formcode.php’); ?> into pages 1 and 2, I get nothing viewable when opening pages 1 and 2 except the heading I previously inserted.
Now you did not direct us to do this, but out of curiosity I opened formcode.php directly and got the following error:
Parse error: syntax error, unexpected ‘<‘ in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\TESTING\WEBSITE13\formcode.php on line 2
It’s refering to the first line of code <form method…
This might be silly of me to say but with php aren’t you suppose to ‘echo’ or ‘print’ the html markup? Anyway, I was pretty excited about this because I learned about the “include” method of duplication and that’s going to save me from writing and REwriting my pages as I have not yet dug into Ajax and am still writing my pages the old school way!
Thanks in advance for replys!
Scott
Hello Scott,
If you create a php page, as long as the HTML is not within the <?php and ?> tags, it does not have (in fact can’t) be echoed out. The fact that the formcode as such:
<? include (‘formcode.php’); ?>
does indeed surround it in the tags, so you are correct, the HTML should be echoed out.
That was indeed an oversight in the development of this guide and oddly enough you are the first one to mention it. It could use some refreshing anyway so I will add that to my ‘to do’ list.
Thank you for catching that!
Kindest Regards,
Scott M
Nice work
How can I fetch any URL directly at coding time
In what context are you trying to grab the URL? I”m having trouble understanding your question. Can you provide us more information on what you are trying to do?
Thank You
Thank you!
thanks dear
I need help beacause it won;t work
Hello Shane,
Thank you for contacting us. This guide is just one of a full tutorial series on Using PHP to create dynamic pages.
Are you having trouble with a specific step or guide?
Thank you,
John-Paul
how we comment on a blog after user login in php
Hello soniya,
Thank you for contacting us. We are happy to help guide you, but it is not clear what you are trying to accomplish.
Please provide additional information and specific details on what you are trying to do.
Thank you,
John-Paul
thanks
could you give me a code to make a comments section that visitors to my site can see
Hello,
Thank you for contacting us. The example of a “Text Box” given above, would allow a customer to add a comment.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
I can’t connect the comment box to my e-mail and I can’t receive the comments. Is there any codes or tags (HTML) to receive comments?
<form action=”MAILTO:my email” method=”post” enctype=”text/plain”>
<webmaster_email= “my email”>
<a href=”file:///C:/Users/HP/Downloads/x.htm”> … </a>
<a href=”file:///C:/Users/HP/Downloads/x.htm” target=”_self”> a </a>
Name:<br>
<input type=”text” name=”name” value=”your name”><br>
E-mail:<br>
<input type=”text” name=”mail” value=”your email”><br>
Comment:<br>
<input type=”text” name=”comment” value=”your comment” size=”50″><br><br>
<input type=”submit” value=”Send”>
<input type=”reset” value=”Reset”>
</form>
this is the code/tags that I’ve used.
Hello Steph,
The way you have the code will cause an email application to open on the visitor’s side with the content of the form in it. From there, they will send the email to you.
If you wish to have the form take the content and send it to your email from the server, then it needs to be passed to a php file that will process and create the mail on the server side.
Kindest Regards,
Scott M
thanks it helped alot
are there ways to upload website free of cost…?
Hello henna,
Thank you for contacting us. It would require you to sign up for a Hosting Plan, to upload a website to our servers.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
I want to add ambient video background in my website but don’t know how to add components on it…please guide…
Hello Henna,
We do not have an article on that, but I did find a tutorial online that may assist you.
Kindest Regards,
Scott M
I do not currently have an article for the format, but do not follow the same principles.
Hi,
I‘m learning to make comments like that, I certainly can,
thanks article msangat help.
I’m with Blacky. How do we assign a page an “id” for the form to get?
Hello Jay,
That is discussed in Step 2 of the previous article in the series.
Kindest Regards,
Scott M
We currently do not have an article for that format, but it does follow the same principles. We are happy to assist with individual questions as you work towards that. This may be a project we take on in the future, however.
I have a question how do you make a comment that everyone could see, like youtube, tier are comments on youtube that every one could see, and how do you make a reply button.
Due to time constraints I am not able to provide specific code. You would need to code part of the page that pulls the comments from the database.
nic work
I have a question how do you make a comment that everyone could see, like youtube, tier are comments on youtube that every one could see, and how do you make a reply button.
Hello Justin,
That would require additional coding. We do not have any readymade scripts on hand for that type of thing at this point. You may want to see if you can find a freelancer to add the additional functionality to your site.
Kindest Regards,
Scott M
HEllow Freind
Can anyone please send me the detail code to create and to display the comment box on my website and to get notification that the user had commented on my website please.
Thanks
Hello Sangay,
Thanks for the question. Unfortunately, we cannot provide you code beyond what has been provided in these tutorials. If you put some of these together, you will get most of what you need. If you require other information, then you may want consult with a programmer or look at other educational sites on using PHP.
I hope that helps to answer your question! If you require further assistance, please let us know!
Regards,
Arnel C.
I just copied that code onto my site. It works, but is there any way that i can view the comments afterwards?
Hello,
You can add an action=”mailto:[email protected]” to have the form email you the results.
Best Regards,
TJ Edens
Could anyone assist me? I’ve set up a mail form in Dreamweaver using PHP. But, when a user fills out the form how do I set it up, so they get a copy of their message? Or even a generated automatic reply from me saying “Thank you for your message, someone will get back to you shortly”
Thanks for your help in advance 🙂
Hello Cheryl,
Thank you for contacting us. You must code/develop a solution with PHP. The above example is part of a full series, where we explain how to accomplish this.
We also provide a working example on our guide How to create a custom PHP contact form with validation.
Thank you,
John-Paul
Hi…
thanks for sharing this blog with us. your content is top of the funnel. always great to receive such brilliant information about such an interesting topic.you have done a great job on this blog.I am impressed with your work.
Hi! My english is very bad, but…
Very good tips. 🙂
How to make comment box so, so all comments saved? For example, we comment and our comments are saved. How i can do the same in my web page?
Thanks forward! :))
Hello One Girl,
To save the comments you would need to add additional code to save the content to a database table.
Kindest Regards,
Scott M
Really a great tips for beginners.I think they will be youlike it and follow you and your website.Please carry on.You should post some more article like it.
How to do comments box for website?
Who con teach me to do comments box?
Thanks.
Hello noomharn,
Unfortunately we do not provide custom coded solutions here in the Support Center. A comment section such as the one here entails coding much like the one above along with a database and the code for members to log in. You may be able to locate tutorials for each specific step along the way by using your favorite search engine. Other people simply hire a developer to create the functionality for them.
Kindest Regards,
Scott M
how to get a complete form in html to connect to your database where a user can full out a form and submit it
Hello Star,
The next article answers your question. Please see using PHP. This tutorial series answer your question.
Regards,
Arnel C.
this is a good artical bt is there a way to report this information in a simple way so that say 100 comments can be seen and collated
Hello Chris,
I’m certain that is possible, however we do not have an article that covers such a situation. That would need to be custom coded.
Kindest Regards,
Scott M
IT DOESN’T WORK!! IT SHOWS BUT WHEN YOU POST NOTHING SHOWS UP!!
Hello Anonymous123,
Thank you for your question. This guide is “Section 3” of a 7-part series on “Using PHP to create dynamic pages.”
Have you completed the other tutorials as well?
Thank you,
John-Paul
I appreciate your blog post, beautifully expressed and well written.
Plesase add how we can save the comment
Hello Ankit,
Thank you for your question. This is just Section 3 of a full series on Using PHP to create Dynamic Pages.
Later in the guide, it covers Using PHP to INSERT data into a database.
Thank you,
John-Paul
Thanks for sharing a nice blog.I really like your post.
I would like to buy something like that but I would not want a monthly subscription just a 1 time payment, would you guys be able to make something like that ?
Hello,
Unfortunately that is outside the scope of what we would be able to do as do not provide custom coding to anyone.
Best Regards,
TJ Edens
Can you make a comment box where you can edit the HTML and if you have a certian IP you can edit and/or delete comments ?
-Regards
Hello Jorden,
We do not have any specific code for something like that, but you that is certainly something that can be custom coded. Instead of using IP addresses, most would simply add some kind of membership feature with specific permissions.
Kindest Regards,
Scott M
Thanks for sharing
Thanks a lot for the tutorial.
I build the form, but didn’t get how to manage so that when someone hits the submit, his/her comment be forwarded to my email address.
Could you please guide me.
What you’re looking for sounds like you’re trying to create a contact form rather than the comment box that is described in this article.
Please give all of the codes. I am beginner and liked this comment box very much but I didn’t understand all. Is there anybody who can tell the codes that I must write on html? All steps…
Hello muratnil,
Thank you for contacting us. Have you followed the above guide? It provides the HTML codes you need to create an HTML form.
Is there a step above that you are having trouble with?
Thank you,
John-Paul
Great! It helped me!
But is there a way that can print the comment with the name on the webpage ?
Thanks
Hello Mudit,
Thank you for your question. The above guide is just Section 3 of a full series on Using PHP to create dynamic pages.
If you follow the class to the end, you will see how to show the comments on the page.
Thank you,
John-Paul
Awesome sauce!
Thanks for sharing this blog..
Hey Guys,
Great article, do you have a simple code for setting up something like this question and comment section?
Hello Melissa,
We currently do not have an article for that format, but it does follow the same principles. We are happy to assist with individual questions as you work towards that. This may be a project we take on in the future, however.
Kindest Regards,
Scott M
This blog is very nice.thanks for our sharing.
Awesome!
awesom article
hey there
it is informative
GUYS HELP THE CODE DOES NOT FETCH DATA FROM THE DATABASE
ANY HELP?
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”https://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
<body>
</style>
</head>
<h1 class=”page-title” align=”center”>AVAILABLE READY PASSPORTS</h1>
<body>
</b>
<hr >
<img src=”passport@1 (1).jpg” width=”318″ height=”161″/>
<img src=”coat.jpg” width=”182″ height=”161″/>
<img src=”passport@1 (3).jpg” width=”330″ height=”161″ />
<img src=”passport@1 (1).jpg” width=”358″ height=”161″ />
<center></center>
<hr/>
<table width=”1285″ background=”passport@1 (1).jpg”>
<tr>
<td width=”194″><a href=”passport2.html”>HOME</a> </td><td width=”247″><a href=”administators.html”>ADMINISTRATORS</a></td><td width=”300″><a href=”FORM A.php”>APPLICANTS</a></td><td width=”246″><a href=”availablepassports.php”>PASSPORTS</a></td><td width=”274″><a href=”ABOUT US.html”>ABOUT US</a></td>
</tr>
</table>
</p>
<?php
$con=mysql_connect(“localhost”,”root”,””);
if(!$con)
{
die(‘could not connect:’.mysql_error());
}
$sql1 = “CREATE DATABASE IF NOT EXISTS myproject”;
if (mysql_query($sql1) === TRUE)
{
echo “Database created successfully”;
}
else
{
echo “Error creating database: ” . mysql_error();
}
mysql_close($con)
?>
<?php
$con=mysql_connect(“localhost”,”root”,””);
if(!$con)
{
die(‘could not connect:’.mysql_error());
}
mysql_select_db(“myproject”,$con);
$sql3=”CREATE TABLE IF NOT EXISTS project(Surname varchar(50) ,Othername varchar(50),DOB varchar(50),email varchar(50),Telephone int(20))”;
if(mysql_query($sql3,$con))
{
$sql=”INSERT INTO project VALUES(‘$_POST[surname]’,’$_POST[other_name]’,’$_POST[DOB]’,’$_POST[email]’,’$_POST[telephone]’)”;
if(!mysql_query($sql,$con))
{
die(‘error:’.mysql_error());
}
else
echo “1 record added”;
}
else
{
echo “Error creating table: ” . mysql_error();
}
/*
$name=$_POST[‘surname’];
$other_name=$_POST[‘other_name’];
$DOB=$_POST[‘DOB’];
$Email=$_POST[’email’];
$Telephone=$_POST[‘telephone’];
mysql_select_db(“myproject”);
*/
mysql_close($con)
?>
</body>
</html>
Hello Kigozi,
I see CREATE statements, which creates tables for the database, but there is not a SELECT statement in the code. SELECT is the type of statement needed to get data out of the database.
Kindest Regards,
Scott M
Many Thanks to you!
nice tips thanks for share
idk, make it to where it works!
Hello mr programer,
This article is part of a series, so this particular piece does not create a fully functioning form alone. Have you also followed the other articles in the series? If so, where are you stuck? We are glad to help.
Kindest Regards,
Scott M
It is really a nice and helpful piece of information. I’m happy that you shared this useful info with us. Please keep us informed like this. Thanks for sharing.
I have read the comments and contribution of the members of this group and i believe that the answer to problem is here. I’m designing a forum but im having a problem opening a specific category generated from a database in another page if the user clicks on it.
In brief i want a situation when a user clicks on a category from the home page, it will take you to that category page with all the topic under the category.
I’m using PHP html for the design. please help me.
Thanks
Hello Eric,
Basically, when clicking the category link, the php will need to pass the category ID on to the next page. That page will then pull the information from the database based on that category ID. We would be happy to help with any specific questions you have if you are getting stuck in implementing this.
Kindest Regards,
Scott M
very good tips.it is very useful.thanks for share..
Thanks for the sharing.
good work
Why do I get invalid article id error.I have a single php page and I want to receive comments one it but I am new on this and I made everything from the tutorials but still nothing ok.please help
Hello Antonio,
We would need to see your page and know the steps you are taking to get the error. If you can provide that we will be happy to see if we can find the error for you.
Kindest Regards,
Scott M
This line of code is wrong:
It should be
Hello error finder,
Thank you for finding that, I have made the correction in the article.
Kindest Regards,
Scott M
how much will it cost to have a dedicated server from inmotion hosting?
Hello,
You can check out our Dedicated server plans and prices here.
Kindest Regards,
Scott M
what i want to know is this when i click on submit which email does it go how do i put in my email to submit insuch a way that when it send i see it .how does the comment show on my webpage
Hello Frank,
This particular series does not deal with email responses. It is for putting comment data into a database. We do have an article on using php for a comment form. This may help you accomplish what you asked.
Kindest Regards,
Scott M
Hello guys! I started coding this website similar to facebook. I had an html corse on w3school, it was helpfull. The question I want to ask is, while I was designing users profile I wanted to add a “what’s up box” that will post both photos and videos. I KNOW THE CODE IS VERY LONG AND WILL TAKE MULTIPLE SEPARATED HTM DOCUMENTS BUT PLEASE ATLEAST ATTACH IT FOR ME ON MY E-MAIL ADDRESS WITH FULL DESCRIBTION! Please!!!
Unfortunately, we would not be able to provide the full code for something like this as we do not provide full development services here, only examples that you may use to put together things on your site. There are, however, systems that are made already to generate social media sites, such as BuddyPress for WordPress, but will still take some development skills to create a fully functional site.
kindly provide a php for replaying a post
Hello Rocky,
We do not provide custom coding requests, but do try and answer questions you may have. Also, as this is not the topic of the article, please ask a new question here so either we or another community member may be able to better assist.
Kindest Regards,
Scott M
Thanks For Your valuable posting, it was very informative.
Hello Reojass,
Thank you for your question. We are happy to help, but there are many resources online for learning Javascript.
Here are some of the most popular resources for learning Javascript:
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
I need to know I have created a form in html with php, when sumeone submit. Their data how can I view that, if they submit their data can I get that via my email. How to code for that? If you know any similar ways plz help me
Ansaf,
My apologies, but I may have left off a tutorial that you can use to accomplish your PHPform. We have a tutorial called Using PHPMailer to send email. This tutorial provides the code and may meet your needs. The PHPmail form basically allows you to create a form that will return to you based on what you have requested with in the form. The data would be returned in email.
I hope this is an easier solution and provides the information that you require. Please let us know if you have any further questions.
Regards,
Arnel C.
hii Friends
how to make a comment box ?
when we set any comment in comment box and press comment button then how to show it top of comment box ?
Within this article, there is a link to the bottom in which it will take you to the next article in the series and eventually ends up at how to grab the comments from the database.
I recommend continuing with this series for a full tutorial on implementing a commenting system.
i want to learn javascript easily can you teach me the basic functions??
Respected Sir,
I want to recieve comments of people in my personal email. how could i do that..
Regards
Awal Khan
Hello Awal,
Thank you for contacting us. Following the above guide will allow people to fill out a page, and it will send the information to your email. Just be sure to update the email information as suggested above.
Also, let us know if you are using a CMS such as WordPress, Joomla, Drupal, or Concrete5. We can then give you an option specific to your software.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
thank you for sharing………
nice tutorial how can i make a registration and login form
in html using php and mysSQL
Hello Ryan,
You can use the same information to create a registration form. Do remember that each page will need to check to see if the visitor is logged on so it will know what information to display.
Kindest Regards,
Scott M
cool
It’s already very good.
nice..
I might have missed something… its getting really late and ive been staring at code too much for some that doesn’t know what they’re doing.
My contact form keeps sending two emails every submission and the context of it is.
Message from Address:
Phone: Email: Fax: fax
Red Maple Acer:
Chinese Pistache:
Raywood Ash:
With no date being received from the form. Any advice is appreciated. I copied the codes from this support site and use it in conjuction with a dreamweaver php page…
Thanks,
Hello Chris,
This particular article has no code related to sending an email. If you can link to the article where you got our code for the email processing we may be able to take a look and see if there is a mistake where it sends two emails.
Kindest Regards,
Scott M
Thank you for your response.
I have used the code provided and have this parse error: syntax error, unexpected ‘)’ in C/xampp/htdocs/testnew/magae_comments.php on line 18. Is there something I did not do well? Please help me. Thank you.
Hello Charlo,
Without seeing your exact code, I cannot tell you exactly what to change. However, check all your parentheses to ensure they are in pairs, for ever ( you must have a ). If you have an odd number, then you will experience an error like this.
Kindest Regards,
Scott M
well done, keep it up!
Below is the php code that give the error message: Notice: Undefined index: comment in C:\xampp\htdocs\testnew\manage_comments.php on line 16
Please help.
<?php
if( $_POST )
{
$con = mysql_connect(“localhost”, “root”, “magicfouru”);
if(!$con)
{
die(‘Could not connect:’ . mysql_error());
}
mysql_select_db(“testnew”, $con);
$users_name = $_POST[‘name’];
$users_email = $_POST[’email’];
$users_website = $_POST[‘website’];
$users_comment = $_POST[‘comment’];
$users_name = mysql_real_escape_string($users_name);
$users_email = mysql_real_escape_string($users_email);
$users_website = mysql_real_escape_string($users_website);
$users_comment = mysql_real_escape_string($users_comment);
$articleid = $_GET[‘id’];
if( ! is_numeric($articleid) )
die(‘invalid article id’);
$query = “INSERT INTO `testnew`.`comments` (`id`, `name`, `email`,
`website`, `comment`, `timestamp`, `articleid`) VALUES (NULL, ‘$users_name’,
‘$users_email’, ‘$users_website’, ‘$users_comment’,
CURRENT_TIMESTAMP, ‘$articleid’);”;
mysql_query($query);
echo “<h2>Thank you for your comment!</h2>”;
mysql_close($con);
}
?>
Hello Charlo,
Thank you for providing detailed information. This may be caused by a user leaving nothing in the comment field.
Try using something like this, which will just fill in the field:
I hope this helps. If you have any further questions, feel free to post them below.
Thank you,
-John-Paul
Thank so much for your kind reply. I did followed the lessons 2-6 through to the final stage , but yet comment from the pages does not register in database and does not show on the pages. Instead I got this Notice: Undefined index: comment in C:/xampp/htdocs/testnew/manage_comments.php on line 16 How do I get this resolve? Please help.
To identify the issue, could you provide us with the code that you have on line 16 as well as the surrounding lines?
Hello sir,
i want a code that when i click a submit button it should be submitted and i should get a another comment box to post oyhers also with reply like your comment box.
What you are describing would need a significant amount of code within both the comment box, as well as the way the page is displayed in which we unfortunately cannot develop this entire solution for you.
One known commenting system is Disqus which will handle all of your commenting code for you. Outside of this, you may want to speak to a developer to have it custom coded for you.
thank u verymuch ,its very use full thank u so much and nice to meet u
hello,
i need to create one Contact us Page using PHP please sendme the sample code
Hi Bala,
If you need sample code for creating a contact page, I recommend reading the tutorial series we have here: 205: Using PHP to create dynamic pages
You may also find it easier watching a video on how to use PHPMailer or this article about using FormMail.
helo please help me?
i can’t manage to connect my website to mysq. i install wamp software and created a database that i want to connect to my website but i can’t able to connect it help me
Hello Bala,
Thank you for contacting us today. We are happy to help, but I am not sure what you asking for.
Please provide more detailed information, so we can assist you further.
If you have any further questions, feel free to post them below.
Thank you,
-John-Paul
Hello Eskinder,
To connect your php to a myswl database, you will want to take a look at our article on Using PHP to insert Mysql
Kindest Regards,
Scott M
hi,
please sned me the following code Abt PHp
nice man..good work..i like this article
Include videos and some other interactive media.
Hello Gerard, and thank you for your suggestion.
I’ll go ahead and add this article to our list of ones that could use an update with some video.
Thanks again.
– Jacob
hello sir can u help me to validate a login section like username and password validation using javascript function in a html page
Hello Sunny, and thanks for your comment.
What did you want to validate your username and password sections against, just that they were filled in? You might have better luck with simply using HTML5 form validation that is now available. For instance you could just use the required option like this:
<input type="text" name="username" required>
For password validation, you might want to try something using a combination of both like this password validation using regular expressions and HTML5.
Please let us know if you had any other questions.
– Jacob
I have followed your tutorials deligently and implemented all the steps, but got stock when comments from my example pages where not recorded at the database. every other thing works well. How do i get comment register at the database?
Hello charlo,
Thank you for your question. Did you complete Sections 2-6 in our series on Using PHP to create dynamic pages?
If you have any further questions, feel free to post them below.
Thank you,
-John-Paul
hello sir/mam
how can sent a comment/text one page to another page without using sesssion is any diffrent way to sent some text one page to another page.
Hello Suman,
Thanks for the question. This kind of thing can be done many different ways depending on the code that you’re using. We can’t always provide you the specific code, but hopefully, this link provides a PHP solution that meets your needs. You can find a tutorial on passing post data here.
Regards,
Arnel C.
Thanks for the Help !!!!!!!!!!!!!!!!!! 🙂
hello sir/mam
can you pls provide me with the code for posting comment which are add below.
Thank you
Hello bhaskar,
We currently do not have general code samples for creating a comment section. This type of feature is usually included as part of the Content Management System such as WordPress, Joomla, Drupal, etc. Creating a comment feature would take much more coding and database interaction. You may want to check and see if there is such a feature for your program. Also, if it uses modules and plugins, there may be one for comments.
Kindest Regards,
Scott M
Hi ,
I am trying put the comment box is right of the form. after the name and email feilds..
Please help me..
Thanks.
Hello Abhishek,
Creating a discussion forum is much more complex. My recommendation would be to use something like PHPBB to do so.
Hello Sam A,
To use a custom alignment, you would need to use some custom CSS to show them appropriately.
Hello Sir/mam,
Can you pls provide me with the code for creating discussion forum.
Thank you
super tips
Very nicely covered and it works too. Many thanks. Let me if you any such more tutorials.
hallo, please help me, i get invalid article id, i already follow all the instruction and no such
php?id=1
at my page, im using phpadmin v 5.1,without article id, nothing i can progress. tq