Thread: Shoutbox
View Single Post
  #1 (permalink)  
Old 16-02-2005, 07:26 PM
jepp jepp is offline
Novice Webmaster
 
Join Date: May 2003
Location: Kedah
Posts: 15
Rep Power: 0
jepp is on a distinguished road
Shoutbox

Hi, i got 1 problem.This is my shoutbox script

----------------------------------------

<?php
include ("include/config.php");
?>

<style type="text/css">
body,textarea,input,h2 {font-size: 8pt; font-family: arial;}
h1 {font-size: 10pt; font-family: arial; color: #00000; }
</style>

<?php

$connect = mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error());
mysql_select_db("$dbname", $connect) or die(mysql_error());

function filter($text) {
$replace=array(''=>' <img src="smiles/smile.gif">',''=>' <img src="smiles/sad.gif">',''=>' <img src="smiles/biggrin.gif">',''=>' <img src="smiles/tongue.gif">',''=>' <img src="smiles/wink.gif">','\''=>'',';'=>'','--'=>'');
foreach($replace as $old=>$new) $text = str_replace($old,$new,$text);
return $text ;
}
if(isset($_POST['submit'])) {
//$result = mysql_query("select max(`time`), max(`banned`) from `shout` where `ip` = '".$_SERVER['REMOTE_ADDR']."'");
//$result = mysql_fetch_array($result);
$name = filter(wordwrap(htmlentities($_POST['name']),25,'<br />',1));
$message = filter( substr( wordwrap( nl2br( htmlentities($_POST['message'])),32,'<br />',1),0,250));

if (((time() - $result[0]) > 30) && ($result[1]!=1))
mysql_query("insert into shout(`name`,`time`,`message`,`ip`) values('$name','".time()."','$message','".$_SERVER['REMOTE_ADDR']."')");
else echo "<div style=\"background-color:#99CCFF;\"><h2>Slow down dude!</h2 ></div>";
}

$resultSet = mysql_query("select `name`, `time`, `message` from `shout` order by `time` desc limit 5");
while ($record = mysql_fetch_assoc($resultSet))
echo "<div><br>".$record['name']."<br>\n".$record['message']."<br>\n".date("h:i:s A",$record['time']). "</div>" ;
mysql_close();

?>

----------------------------------------------------

masalahnya sekarang, saya includekan shoutbox.php ni dlm index.php
tapi, lepas saya submit shout, browser akan buka shoutbox.php dan bukan index.php

mcm mana saya nak buat supaya lepas user shout, browser akan buka index.php bukan, shoutbox.php

tq
Reply With Quote