FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Shoutbox + Ajax





DanielXP
Could some one please add ajax to this shout box so it makes it refresh every ones tagboard when some one has made a post.

Like it refreshes ever 20 millie seconds or what ever.

Demo: http://blog.jalenack.com/ajax/

This is my tagbox
Code:
<html>

<head>

<link rel="stylesheet" href="css.css" type="text/css">

</head>

</html>

<?
include("checkban.php");

include("config.php");

include("smbb.php");




switch($_GET['action']) {



case "viewtags":



$color1 = "#D8E6FF"; 

$color2 = "#FFFFFF"; 

$row_count = 0;





$gettags = mysql_query("select * from tag order by id desc limit 10");

while($t=mysql_fetch_array($gettags))







{

$row_color = ($row_count % 2) ? $color1 : $color2;      

   //getting each variable from the table

   $id=$t["id"];

   $name=$t["by"];

   $message=$t["message"];

   



$message2 = "$message";

$message2 = BBCODE($message2);

echo "<table width='100%'>";

echo "<tr><td bgcolor='$row_color' width='100%'>";

echo "<b>";

echo "<font color='#000000'>$name</font>";
echo "</b>";

echo "<br>";

echo "<font color='#000000'>";

echo "$message2";

echo "</font>";

echo "</td></tr>";

echo "</table>";



$row_count++;



}



echo "<meta http-equiv=\"Refresh\" content=\"30; URL=tagboard.php?action=viewtags\"/>";

break;







default:

echo "<body background='bg.GIF'>";



echo "<iframe name=\"tags\" border=\"0\" frameborder=\"0\" width=\"115\" height=\"180\" align=\"center\" src=\"tagboard.php?action=viewtags\" marginwidth=\"0\" marginheight=\"0\"></iframe>";



   if ($logged[username])

   {

echo "<center><form action=\"tagboard.php?action=tagit\" method=\"post\">

<textarea type=\"text\" name=\"message\" rows=\"3\" cols=\"12\" onclick=\"this.value=''\">Message</textarea>

<input type=\"submit\" name=\"submit\" value=\"Tag\" size=\"20\">

</form>";

echo "</center>";

}
else
{
echo "<meta http-equiv=\"Refresh\" content=\"30; URL=tagboard.php\"/>";
}



break;



case "tagit":

$name = $logged[username];

$message = nl2br(htmlspecialchars($_POST['message']));

$ip = $_SERVER['REMOTE_ADDR'];



If (!$name){

   print "You must enter your name!";



}

else

{

$result=MYSQL_QUERY("INSERT INTO `tag` (`by`,`message`,`ip`) VALUES ('$name', '$message', '$ip')");



echo "<meta http-equiv=\"Refresh\" content=\"0; URL=tagboard.php\"/>";



}

break;



}

?>


Thanks if you will or can do this for me Smile
Related topics
A use for Ajax?
AJAX tutorial
shoutbox please
AJAX based 5 star rating script
Thinking of change
First XMLHttpRequest Object Project - A refreshless shoutbox
PHP Tutorial: Basic Shoutbox w/ MySQL
AJAX - asynchronous JavaScript and XML
A Ajax tutorial
Free Shoutbox Scripts
Shoutbox?
AJAX?
Shoutbox Problem
questions about my shoutbox experiment
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.