Forum Moderators: coopster
<head>
<title>.: omni :.</title>
<link rel="stylesheet" href="text.css" type="text/css">
</head><?php
#change localhost to the sql server, user to the correct username, and pass to the correct password
$con = mysql_connect("localhost","****_****","*******")
or die("Unable to establish a connection to the database.");#change database to the database name
$database = "******_*****";
$db = mysql_select_db("$database") or die("Couldn't select database $database.");// IP Banning Function
function ipbanning ($addr)
{
$banned_ips = array();
$banned_ip[] = array(' \123.123.***.***', ' banned');
$banned_ip[] = array(' \123.123.***.***', ' banned');// continue adding list of banned ips where necessary.
foreach ($banned_ips as $banned_ip) {
$addr = eregi_replace($banned_ip[0],$banned_ip,$addr);
}
return trim($addr);}
// do the check for ip banning
$ip = ipbanning($REMOTE_ADDR);
if ($ip=='banned')
{
die ("IP banned, you cannot post shouts.");
}// do a basic check, don't let user submit a blank entry.
if ($name == '' ¦¦ $msg == '' ¦¦ $name == 'name' ¦¦ $msg == 'message')
{
die ("Error! You cannot fill in an empty shout. Please try again.");
}// strips off weird characters and HTML tags
$name = htmlspecialchars($name);
$msg = htmlspecialchars($msg);// do check here
$last_entry = "select * from shoutbox order by id desc";
$check = mysql_query($last_entry);while ($row = mysql_fetch_array($check))
{
$oldname = $row["name"];
$oldmsg = $row["msg"];
}// compare the values of old and new entry
if ($oldname == $name && $oldmsg == $msg) // means the name and msg entered is the same
{
die ("Error! Duplicate entry detected, please submit only once.");
}// insert into database
$q = "insert into shoutbox (id,name,msg) VALUES ('','$name','$msg') ";
$result = mysql_query($q);if ($result)
{
// success so redirect user to view shoutbox.
$siteurl = 'view.php';
header('Location: [site.com');...]
}?>
[1][edited by: jatar_k at 3:17 am (utc) on Oct. 5, 2003]
[edit reason] generalized [/edit]
if ($result)
{
// success so redirect user to view shoutbox.
$siteurl = 'view.php';
redirect();
}
function redirect() {
echo "<meta http-equiv=\"refresh\" content=\"3;URL=http://www.site.com\">\n";
echo "Thank you, please wait....\n";
exit;}
?>
Or something like that.
And welcome to Webmaster World.
:)