PDA

View Full Version : php code help



Colin-Roberts
14-10-2006, 07:59 PM
ok i have a shoutbox that is in a table in my layout but everytime someone submits a shout in order for it to add the shout it has to refresh the hole layout wich is annoying is there anyway i can make it just add the shout not refresh the layout:

addtag.php code

<?php
$name = $_POST['name'];
$website = $_POST['website'];
$message = $_POST['message'];

if(empty($name) OR empty($message))
{
echo "

<script language='javascript'>

alert('You need to fill out both of the form fields...');

</script>
";

}
else
{

echo "
('');
";
$name = htmlspecialchars($name);
$message = htmlspecialchars($message);
$tag = ("<font size=\"1\" face=\"Verdana\">
<b>$name</b>: $message </font><br><br>");
function filter($tag)
{
$bad_words = explode(',', "tomato,lettuce,carrot,potato,broccoli,cucumber,pea" );
foreach ($bad_words as $naughty)
{
$tag = eregi_replace($naughty, "****", $tag);
}
return $tag;
}
function filter2($contents)
{
$bad_words = explode(',', "tomato,lettuce,carrot,potato,broccoli,cucumber,pea" );
foreach ($bad_words as $naughty)
{
$contents = eregi_replace($naughty, "****", $contents);
}
return $contents;
}

$read = fopen("content.txt", "r");
$contents = fread($read, filesize('content.txt'));
fclose($read);

$write = fopen("content.txt", "w");
fwrite($write, "$tag $contents");
fclose($write);
}
$input = $contents;
$output = filter($input);
echo $output;
$input = $tag;
$output = filter($input);
echo $output;

print "<meta http-equiv=\"refresh\" content=\"0;http://www.colin-roberts.net/test/index2.htm\">";

// Copyright 2006 - 2007 Colin-Roberts.net

?>

Connect-Hosting
14-10-2006, 08:09 PM
"<meta http-equiv=\"refresh\" content=\"0;http://www.shoutbox url here\">";

Colin-Roberts
14-10-2006, 08:14 PM
already got that and when it does it refreshes everything or do you mean remove that?

Tomm
14-10-2006, 08:37 PM
Use AJAX :)

Kymux
14-10-2006, 09:22 PM
AJAX IS EASYY!

Want to hide these adverts? Register an account for free!