Help after successful login
Posted: Mon Dec 06, 2010 9:29 am
I am using a premade chat script that at first just allowed users to put in a username, and then they would enter the chat. So i used a login/registration script but when I have the user go to the chat page, I cant figure out how to make it post THEIR USERNAME in the chatroom.
The code on the CHAT page is
That is from when the user posted on the original form. But I am not sure how to have it use the username from the database into the chat.
Any ideas?
The code on the CHAT page is
Code: Select all
<?
if (!$_POST["username"]||$_POST["username"]=="Guest") $username="Guest".rand(1000,9999);
else $username=$_POST["username"];
$username=preg_replace("/[^0-9a-zA-Z_]/","-",$username);
$usertype=$_POST["usertype"];
$userroom=$_POST["room"];
$userroom=preg_replace("/[^0-9a-zA-Z\s_]/","-",$userroom);
setcookie("username",urlencode($username),time()+72000);
setcookie("usertype",urlencode($usertype),time()+72000);
if ($userroom) setcookie("userroom",urlencode($userroom),time()+72000);
?>Any ideas?