Qbasicnews.com

Full Version: Html Comment Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Is it possible to append data (just plain text) to a file in HTML, to make for example a comment script, or is that kind of thing only possible using a server technology like PHP?
Quote:Is it possible to append data (just plain text) to a file in HTML, to make for example a comment script, or is that kind of thing only possible using a server technology like PHP?
Not in HTML. It has no Read/Write or just plain file capabilities.

Instead, you can use PHP.
Code:
<?php
echo "Here is you comment";
if ($i == 0) print "Another comment";
for ($i = 0; $i < 10; $i++)
   echo "Comment $i";
?>
Read a tutorial or so about PHP Smile
...The Geekery has a simple tagboard that uses php and mysql, if you want to take a look at the script, PM me.
Ok thanks guys. I know how to use PHP, i program using it on a school server, but my website doesnt support PHP Sad (free web host)
how about cgi? cgi can read/write also
cgi is just any server side program (common gateway interface). But because until 1997 Perl pretty much had 99% of the cgi share, servers recognize ".cgi" files as Perl files, so you're probably thinking of Perl, Potato. The "official" extension of these files is ".pl" back from the Unix days, but ".cgi" has such a better ring to it Wink Those can be executed as ".pl", ".cgi" files, or mixed with html files in ".shtml" files, or even executed from PHP scripts through the virtual() function.

Dark_prevail: PHP and Perl are very (and I mean very) similar languages, right down to syntax) and are about equally popular, PHP having like a 2% edge from the Apache surveys I've read, so it wouldnt hurt you to learn Perl as well, you learn one you pretty much know the other. If you're interested in learning either of them, there are some very good tutorials online for both PHP and Perl I can link you to.
Ah, .shtml files are Perl files mixed with HTML? Didn't know that. Smile
!#/usr/bin/perl -w
;use stric
Eh? Is that the beginning of every .shtml file?
no. shtml is a simple cgi that apache invented for their servers. It had a number of limited abilities stuffed into tags such as a counter or the date, that would be parsed by the server and replaced with html. One of the function tags was include, which would insert an html file in its place, and if you told it to include a .cgi or a .pl file, it would replace it with the output of the mentioned script.

Code:
<!--#include virtual="header.html"

or
Code:
<!--#include virtual="myscript.pl"

would replace that tag with the html output of the mentioned file. It's an apache-only thing, as far as I can remember. Or at least they were the first to do it. I only mentioned it because it's one of the ways you can integrate perl with html (though I always just print my html from the .cgi script and call it directly).

Think of it this way: shtml is html with a few special tags that are handled server-side.

some more special shtml tags:
http://httpd.apache.org/docs/howto/ssi.html

Quote:!#/usr/bin/perl

this is how you must begin every perl file, so that the server knows where the perl binary is. it's kind of petty, every one uses the same location, but just put that at the top of your programs if you're writing cgi or you'll get an error.
Pages: 1 2 3