Location: PHPKode > projects > pmchat > pmchat/login.php
<html>
<head>
<LINK href="style.css" rel="stylesheet" type="text/css">
<script src="util.js"></script>
<script src="addkiller.js"></script>
<script language="javascript">
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function init()
{
	var str="Invite Others by sending to join this chat room by sending this link :";
	str+="<a href='"+location.href+"' target=_blank>Chat Room</a>";
	document.getElementById("clk").innerHTML=str;
}

<?
include('db.inc');

$action="";

	$chatroom="";
	if(isset($_GET['chatroom']) && !empty($_GET['chatroom']))
	{
	$chatroom=$_GET['chatroom'];
	}
	if(isset($_POST['chatroom']) && ! empty($_POST['chatroom']) )
	{
	$chatroom=$_POST['chatroom'];
	}

	if(isset($_GET['action']) && !empty($_GET['action']))
	{
	$action=$_GET['action'];
	}


?>
function submitmyform()
{
if(document.enterform)
{
document.enterform.submit();
}

}

</script>
</head>
<body onload="init()">

<?
if($action=="")
{
	
printLoginForm('',$chatroom);



/*if(isset($_COOKIE['ezchatuserid']))
{
	$c_userid=$_COOKIE['ezchatuserid'];
	if($c_userid!="")
	{
	submitForm($_COOKIE['ezchatuserid'],$_COOKIE['ezchatusername']);
	}
	else
	{
	printLoginForm('',$chatroom);
	}
}
else
{
printLoginForm('',$chatroom);
}
*/
}
else if($action=="login")
{
$nickname=$_POST['nickname'];

$query="select * from UserStatus where USERNAME='".$nickname."' and ACTIVE='1' and ROOMID=".$chatroom;
$res=mysql_query($query);
if($row=mysql_fetch_array($res))
{
printLoginForm('User with this name had already logged in.',$chatroom);
}
else
{
$query= "insert into UserStatus (USERNAME,ACTIVE,ROOMID) values ('".$nickname."','1',".$chatroom.")";
$res=mysql_query($query);

$query= "select * from UserStatus where USERNAME='".$nickname."' and ACTIVE='1' and ROOMID=".$chatroom;

$z=mysql_query($query);
if($z)
{
$userrow=mysql_fetch_array($z);

$userid=$userrow['USERID'];
$username=$userrow['USERNAME'];

?>

<table bgcolor="#c61111">
<tr><td class="whitefont">Loading...</td></tr>
</table>
 
<form name="enterform" action="chatContent1.php?chatroom=<?echo $chatroom;?>" method="post">
<input name="userid" value="<?echo $userid?>" type="hidden">
<input name="username" value="<?echo $username?>" type="hidden">
<a href="javascript:document.enterform.submit()">Click here</a> to continue
</form>
<script language="javascript">
//isetCookie('ezchatuserid','<? echo $userid ?>',1);
document.cookie="ezchatuserid=<?echo $userid ?>";
document.cookie="ezchatusername=<?echo $username ?>";
document.enterform.submit();
//setTimeout('submitmyform()',1000);
</script>
	<?
	}//inner if

	}

}
?>



</body>
</html>

<?
function printLoginForm($msg,$chatroom)
{
	$query= "select * from ChatRoom where ROOMID=".$chatroom;

	$z=mysql_query($query);
	if($z)
	{
		$userrow=mysql_fetch_array($z);

		$rname=$userrow['ROOMNAME'];
		$rcomment=$userrow['CHATCOMMENT'];
	}

?>
        <!--form name="loginform" method="post" action="login.php?action=login">
        Nick Name : <input type="text" name="nickname" size="25"> <input type="submit" name="Login" value="Login">
	</form-->
        <form name="loginform" method="post" action="login.php?action=login&chatroom=<?echo $chatroom;?>">
	<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 height="100%">
  <TBODY>
	  <TR>
    <TD vAlign=middle align=center>
	<?
	if($msg)
        {
	?>
	<table width="100%" align="center" cellpadding="5" cellspacing="0" border="0">
	<tr>
		<td align="center"><span style="background-color:orange" class="textblue">
	<?echo $msg;?>
	</span></td>
	</tr>
	</table>
	<?
	}
	?>

      <TABLE class=outbrd1 height=202 cellSpacing=0 cellPadding=0 width=750
      align=center border=0>
        <TBODY>
        <TR>
          <TD width=10 height=230>&nbsp;</TD>
          <TD vAlign=top height=230>
            <TABLE cellSpacing=0 cellPadding=4 width=469 border=0>
              <TBODY>
              <TR>
                <TD class=homeHeader vAlign=bottom width=202 height=30>
                <a href="http://pmtracker.siteburg.com" target=_blank><img border="0" src="./images/pmchat.gif" alt="PM Chat" title="chat logo"></a></TD>
                <TD class=homeHeader vAlign=bottom align=right width=267
                height=30>&nbsp;</TD></TR>
              <TR>
                <TD class=text align=left width=469
              colSpan=2>&nbsp;</TD></TR></TBODY></TABLE>
            <TABLE class=textblue cellSpacing=0 cellPadding=0 width="97%"
            align=center border=0 >
              <TBODY>
              <TR>
                <TD vAlign=top align=middle>
                <img border="0" title="chat features" alt="chat features"  src="./images/progress.gif" width="18" height="18"></TD>
                <TD class=text1 width=426>Private Group Chat</TD></TR>
              <TR>
                <TD vAlign=top align=middle>
                <img border="0" title="chat features" alt="chat features" src="./images/progress.gif" width="18" height="18"></TD>
                <TD class=text1>No Registration Required</TD></TR>
              <TR>
                <TD vAlign=top align=middle>
                <img border="0" title="chat features" alt="chat features" src="./images/progress.gif" width="18" height="18"></TD>
                <TD class=text1>No Applet Download Needed</TD></TR>
		<TR>
                <TD vAlign=top align=middle>
                <img border="0" title="chat features" alt="chat features" src="./images/progress.gif" width="18" height="18"></TD>
                <TD class=text1>Unlimited number of users</TD></TR>
		<TR>
                <TD vAlign=top align=middle>
                <img border="0" title="chat features" alt="chat features" src="./images/progress.gif" width="18" height="18"></TD>
                <TD class=text1>Unlimited number of chat rooms</TD></TR>
              <TR>
                <TD vAlign=top align=middle>&nbsp;</TD>
		<TD class=text>&nbsp;</TD></TR>
		<TR>
		<TD colspan=2 >
		<span id=clk class=textblue></span>
		</TD>
	</TR>
              <TR>
                <TD vAlign=top align=middle colSpan=2>
                  &nbsp;</TD></TR></TBODY></TABLE>
		  
		  </TD>
          <TD width=10 height=230>&nbsp;</TD>
          <TD vAlign=top width=250 height="100%" rowSpan=3>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 height="100%">
              <TBODY>
              <TR>
                <TD vAlign=top bgcolor="yellow" height="100%">                
                  <TABLE class=textblue style="BORDER-COLLAPSE: collapse"  borderColor=#111111  cellSpacing=0 cellPadding=5    width="100%" bgColor=#CFDFFF border=0	 height="100%">
                    <TBODY>
                    <TR>
                      <TD align=middle colSpan=3 height=12>&nbsp;</TD></TR>
		      <TR>
                      <TD class=homtTextBold align=right width="36%" height=25>
		      Chat Room
		      </TD>
		      <td>:</td>
                      <TD width="64%" height=25>
		      <?echo $rname;?>
		      </TD>
		      </TR>
		      <TR>
                      <TD class=homtTextBold align=right width="36%" height=25>
		      Description   
		      </TD>
		      <td>:</td>
                      <TD width="64%" height=25>
		      <?echo $rcomment;?>
		      </TD>
		      </TR>
                    <TR>
                      <TD class=homtTextBold align=right width="36%"
                        height=25>Nick Name</TD>
			<td>:</td>
                      <TD width="64%" height=25>
			<INPUT type=hidden value=html name=clienttype> 
                      <INPUT type="text" class=loginTextfield  name="nickname" size="20"> </TD></TR>
                    <TR>
                      <TD height=25>&nbsp;</TD>
                      <TD height=25 colspan=2><INPUT class=loginButton id=Submit3 type=submit value="  Login  " name=Submit onclick="location.href='home.html'"></TD></TR>
                    <TR>
                      <TD vAlign=top align=left colSpan=3 height=113>Nick Name 
                      should be at least 4 characters and at most 10 characters&nbsp; 
                      in length. </TD></TR></TBODY></TABLE>
                
                </TD>
                </TR>
                </TBODY>
                </TABLE>
                
                </TD></TR>
        <TR>
          <TD height=1></TD>
          <TD class=text align=left height=1></TD>
          <TD height=1></TD></TR>
        <TR>
          <TD height=8></TD>
          <TD class=blackfont align=middle height=8>Best viewed in IE 5.5
            &amp; above, Opera 7.2 &amp; above, Netscape 7.0 &amp; above, at a
            Screen Resolution of 1024 X 768 pixels.</TD>
          <TD height=8></TD></TR>
          </TBODY>
          </TABLE>
          </TD>
          </TR>
          </TBODY>
          </TABLE>

	</form>          


<?
}

function submitForm($userid,$username)
{
?>
	<form name="enterform" action="chatContent1.php?chatroom=<?echo $chatroom;?>" method="post">
        <input name="userid" value="<?echo $userid?>" type="hidden">
        <input name="username" value="<?echo $username?>" type="hidden">
        </form>
	<table bgcolor="#c61111">
	<tr><td class="whitefont">Loading...</td></tr>
	</table>
	<a href="javascript:document.enterform.submit()">Click Here</a> to continue
        <script language="javascript">
        document.enterform.submit();
	//setTimeout('submitmyform()',1000);
        </script>
<?
}
?>
Return current item: pmchat