Hello,
i have a shoutbox which has anonymous hard coded into it and, i was wanting to say if user = anonymous then redirect to login/register? Is there a simple way of doing this with my code or would i need to try and rewrite the shoutbox?
[code]<?php
include(“config.php”);
include(“mainfile.php”);
$link = mysql_connect($dbhost, $dbuname, $dbpass);
@mysql_select_db($dbname);
cookiedecode($user);
switch($op){
case write:
$msg = $_POST[‘shout’];
$time = time();
$user = $cookie[1];
if ($user == “”) {
$user = “Anonymous”; // needs changed here.
}
$result = mysql_query(“INSERT INTO “.$prefix.”_shout (UID, PDT, MSG)
VALUES (’$user’, ‘$time’, ‘$msg’)”) or die(mysql_error());
case read:
$query = mysql_query(“select * from “.$prefix.”_shout ORDER BY PID DESC”);
$nrows = mysql_num_rows($query);
$msg = “output=”;
for($i = 0; $i < $nrows; $i++) {
$row = mysql_fetch_array($query);
$time = strftime("%a %m/%d/%y %H:%M", $row[‘PDT’]);
$msg .= “
” . $row[‘UID’] . " " . $time . “
”;$msg .= “
”.$row[‘MSG’] . “
”;$msg .= “
------------------------------------------------------------------
”;
}
$msg .= “”;
echo $msg;
$user = $cookie[1];
if ($user == “”) {
$user = “Anonymous”; // also needs changed here.
}
$msg2 = “&username=”;
$msg2 .= $user;
echo $msg2;
break;
default:
die ("You can't access this file directly...");
}
mysql_close($link);
?>[/code]
there are no shoutbox tables, it just inputs it into the database.