On many blogs, where you type a response, comment etc, I was wondering, are these boxes just HTML textfields with something like PHP attached to them…?
Can anyone explain how the code for soemthing like this would be written…? I guess its sent to the database and the page is reloaded once its been submitted but apart from that Im not sure what else to think about if I was write to my own.
Most of today’s blogs use Wordpress which has a build in comment system which can be styled to look different from the stock version. On most custom blogs it would be as you said just a standard HTML form with a PHP back end that validates the values and such.
Hi,
I want to say that, most of the users use WordPress for their blogs and after submission if you look at WordPress files, take a look at the comments.php template file. That is what is responsible for displaying the form as well as the comments. And it is all about the plugin in wordpress written in
Say if I was to write it myself, would it be a very big task…?
Adding users/signups etc would probably be quite big.
Just wpres is very confusing to me in so many One way is how can you SEO your meta tags etc relevant to each page if they all come from the same template structure,
To be honest I just really like the idea of doing it myself but Im still very new to PHP
Ethan, the form POSTs to a PHP script. It would access the $_POST variables to check them out, and if valid insert into the database. The form element name will be how you refer to it in post.
e.g. <textarea name=‘comments’> will be available in $_POST[‘comments’] after the form is submitted.
Blogs attract a lot of spam. So if you do this yourself you’ll need to include a few tricks in the form to try and identify automated submissions, and also probably count the number of links. Any links should be rel=“nofollow” to remove the incentive for spammers. You’ll probably still get some, so I’d recommend moderating comments by default.
For security, at minimum you’ll need to strictly limit the HTML allowed with a whitelist (or allow none at all), and use [fphp]htmlentities[/fphp] when displaying the comments.