I am trying to set it up so that when someone who is not logged in tries to post in my shoutbox they get a javascript alert saying that they must be logged in to post. The session is passing and is allowing logged in users to post, and unlogged in users cannot post, but the javascript alert is not triggering. Any help would be greatly appreciated.
here is the code:
<?php
session_start();
if(isset($_SESSION['Username']))
$poster = $_SESSION['Username'];
else
$poster = "";
if ($poster == "") {
echo "<script>alert('You must be logged in to post')</script>"; //this is not working
} else { //everything after this point seems to be working flawlessly
$query = "INSERT INTO shoutbox (poster,message,time) VALUES ('".$poster."','".$message."','".$msg_time."')";
mysql_query($query);
}
KP: Added code tags.