Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Php Chat System

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

3 comments so far (post your own) View All Comments Latest 10 Comments:

i want to download this dbms

Posted by sirin on Wednesday, 09.15.10 @ 16:16pm | #99599

Thanks Rose for the chat code
but i am having problem is not showing anything.
I also try the one u suggested thatt's Mysql deiven chat script below is the code:
function ShowLoginForm() {

?>

<b>Enter Your NickName</b>

<form name="chat" method="post" action="chat.php" target="_top">

<input type="text" name="nick" size="20">

<input type="hidden" name="action" value="enter">

<input type="hidden" name="chat" value="<font color=FF0000><b>Enters the Room</b></font>">

<input type="submit" name="Submit" value="Submit">

</form>

<?php

function Login() {

global $chat;

global $nick;



session_start();

session_register("nick", $nick);

?>

<frameset rows="563,62" cols="*">

<frame name="posts" src="chat.php?action=posts&nick=<?php echo $nick; ?>&chat=<?php echo $chat; ?>">

<frame name="form" src="chat.php?action=form&nick=<?php echo $nick; ?>">

</frameset>

<noframes>

<body>

<p>This page uses frames, but your browser doesn't support them.</p>

</body>

</noframes>

</frameset>

<?php

}
function doSubmit()

{

if(document.chatform.chat.value == '') {

alert('Please enter some text!');

document.chatform.chat.focus();

return false;

}
function GetInput() {

global $HTTP_SESSION_VARS;

global $chat;

global $nick;

?>



<form onSubmit="return doSubmit" name="chatform" method="post" action="chat.php" target="posts">

<input type="text" name="chat">

<input type="hidden" name="nick" value="<?php echo $nick; ?>">

<input type="button" onClick="doSubmit()" name="Submit" value="Say">

<select name="col">

<option>Black</option>

<option>Red</option>

<option>Green</option>

<option>Blue</option>

<option>Orange</option>

</select>



<input type="button" name="DoFace1" value=" :) " onClick="sendFace(1)">

<input type="button" name="DoFace2" value=" :( " onClick="sendFace(2)">

<input type="button" name="DoFace3" value=" :D " onClick="sendFace(3)">

<input type="hidden" name="action" value="posts">

</form>

<script language="JavaScript">

function sendFace(faceNum)

{

switch(faceNum)

{

case 1:

document.chatform.chat.value = ':)';

break;

case 2:

document.chatform.chat.value = ':(';

break;

case 3:

document.chatform.chat.value = ':D';

break;

}



document.chatform.submit();

document.chatform.chat.value = '';

}

function doSubmit()

{

if(document.chatform.chat.value == '') {

alert('Please enter some text!');

document.chatform.chat.focus();

return false;

}

document.chatform.chat.value = '<font color="'+document.chatform.col[document.chatform.col.selectedIndex].text+'">'+document.chatform.chat.value+'</font>';

document.chatform.submit();

document.chatform.chat.value = '';

document.chatform.chat.focus();

return true;

}

</script>

<?php

}
global $HTTP_SESSION_VARS;

global $chat;

global $nick;
print '<meta http-equiv="refresh" content="10;URL=chat.php?action=posts&nick=<?php echo $nick; ?>">';
$svrConn = mysql_connect("localhost", "root", "") or die("<b>Error:</b> Couldnt connect to database");

$dbConn = mysql_select_db("chat", $svrConn) or die ("<b>Error:</b> Couldnt connect to database");
if(!empty($chat)) {

$strQuery = "insert into chatScript values(0, '$chat', '$nick')";

mysql_query($strQuery);

}
$strQuery = "select theText, theNick from chatScript order by pk_Id desc limit 20";

$chats = mysql_query($strQuery);
while($chatline = mysql_fetch_array($chats)) {

print "<b>" . $chatline["theNick"] . ":</b> " . swapFaces($chatline["theText"]) . "<br>";

}
function swapFaces($chatLine) {

$chatLine = str_replace(":)", "<img src='smile.gif'>", $chatLine);

$chatLine = str_replace(":(", "<img src='frown.gif'>", $chatLine);

$chatLine = str_replace(":D", "<img src='bigsmile.gif'>", $chatLine);

return $chatLine;

}
if (empty($action))

ShowLoginForm();

elseif ($action == "posts")

ShowAddPosts();

elseif ($action == "form")

GetInput();

elseif ($action == "enter")

Login();
I got below error:
Parse error: syntax error, unexpected $end in C:\wamp\www\Chat\chat.php on line 235

Posted by ben on Wednesday, 04.21.10 @ 01:47am | #96523

i have tried the tutorial you have posted and it is really helpful but i am having a little problem. i cant view the user's name. what is only posted is the message, not the username...please help me on this asap.thank you very much

Posted by abby on Wednesday, 03.10.10 @ 10:42am | #95431

Ask programming questions?

 

 

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.