Post: [AJAX] Simple html comment box **NGU exclusive script**
05-02-2011, 08:28 PM #1
<Jimbo>
</Jimbo>
(adsbygoogle = window.adsbygoogle || []).push({});
Well I noticed that a lot of people have their own sites, so as the title says... You can put this onto your site and have your own 'comment box'.
You must login or register to view this content.
That has no styling.
Example URL:
You must login or register to view this content.

The following script allows people to post a comment on your site and have it displayed instantly... without you using pre-made features like so.


First, your AJAX script which belongs with in the <head> tag's
    <html>
<head>
<script type="text/javascript">
function formRet()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv2").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","comments.txt",true);
xmlhttp.send();
}
</script>
</head>


Then this which can go anywhere within the <body> of your script.
    <body onLoad="formRet()">


Then have the have the form where people will input their comments in. As so:
    <form action="next.php" method="get">
Name: <input type="text" name="Name" />
Comment: <input type="text" name="Comment" />
<input type="submit" value="Submit" />
</form>

And edit the the values such as Name etc...

The text will be displayed on the loading of the page in the where ever you decide to place this:
    <!--Comment form by Jimbo-->
<div id="myDiv2">This will be replaced by text from the .txt file!</div>
<!--End of comment form by Jimbo-->

Feel free to edit all of the above with your own styling i.e. a CSS style sheet etc...

Then finally copy the following text and save it as "next.php" and upload it in the same directory as the comment box is!
    <?php
$datum = date('d-m-Y / H:i:s'Winky Winky;
header("Location: https://REPLACE THIS WITH THE URL OF THE COMMENT BOX!");
$handle = fopen("comments.txt", "a");
foreach($_GET as $variable => $value) {
fwrite($handle, $value);
fwrite($handle, "
");
}
fwrite($handle, "Date: $datum (Date=0 GTM)
");
fclose($handle);

setcookie ("user", "empty", time()+3600);
exit;
?>


And it really is that simple! :y: Don't forget to style this as you wish to make it look 'unique'!

And of course please leave feed back! Smile
Last edited by <Jimbo> ; 06-12-2011 at 03:02 PM.

The following 2 users say thank you to <Jimbo> for this useful post:

Kombust, thehardcore210
05-06-2011, 03:37 PM #11
<Jimbo>
</Jimbo>
Of course, just PM me your script? And I'll put it in?

Originally posted by warfrat View Post
nice wana help me put this on my site
05-14-2011, 04:32 PM #12
thanks awesome Happy Smile
05-14-2011, 09:55 PM #13
<Jimbo>
</Jimbo>
You're welcome! :y: :wub:

Originally posted by thehardcore210 View Post
thanks awesome Happy Smile
06-12-2011, 02:56 PM #14
Seems we also need the stylesheet because the Form refers to

class="html7magic"

Can you put that up there too please?

Thanks,
AK.
06-12-2011, 03:04 PM #15
<Jimbo>
</Jimbo>
Sorry, I forgot to edit that out ages agoo lol... I've updated the OP and and I will put in a style sheet later. Smile
Originally posted by AlexanderKnox View Post
Seems we also need the stylesheet because the Form refers to

class="html7magic"

Can you put that up there too please?

Thanks,
AK.
08-26-2014, 12:14 PM #16
Default Avatar
Ldb1962
Guest
i use this script on my page, but is it possible to show the comments under name and date? so not all on one line

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo