Redirect anonymous shoutbox help

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.

header() function will help you out with that one. Be sure not to forget to call exit() after it, or else page execution won’t stop.

thanks for the idea, now i have a start. i used include_once(NUKE_BASE_DIR.‘header.php’); then include_once(NUKE_BASE_DIR.‘footer.php’); at the end. what i am unsure of it’s going to be an else if ($user=anon,
if, then put my redirect here.

I’m new to this, this will be my first php mod on a shoutbox.

Thanks for the start.

Thank You,
clyde

Sponsor our Newsletter | Privacy Policy | Terms of Service