I can only show you the code, i am writing my site and hosting it on my own pc with WAMP and cause i am 2nd on a network, wamp don't want to play with the outside world! lol
anyway, this is my code, sorry its messy, i am newish to it all lol
and there is more pages than this that handles the emotions, sending the messages to the database and so on but they not needed
main im page to hold it all together ( private.php )
PHP Code:
<?
include( "../inc/db.php" );
include( "../inc/cookieread.php" );
echo "<BODY TOPMARGIN=0 LEFTMARGIN=10>";
$query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker = $query; include( "../inc/security.php" ); $query = $checker;
echo "Private chat to ".$query."<br>";
echo "<iframe name='$query' id='$query' src='refresher.php?".$query."' height='250' width='305' frameborder='1' scrolling='yes'></iframe>";
echo "<form action='process_message.php' method='post' name='message'>
<input type='hidden' name='too' value='$query' />
<input type='hidden' name='from' value='$id' />
<input id='message' type=' text'size='39' maxlength='1000' name='message'>
</textarea>
<input type='submit' value='Send'>";
include( "smiles.html" );
?>
my file that calls the contents to add to the div (refresh.php )
PHP Code:
<?
$query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker = $quids; include( "../inc/security.php" ); $quids = $checker;
echo "<script type='text/javascript' src='ajax.js'></script>
<script type='text/javascript'>
<!--
function refreshh(name) {
setTimeout('refreshh(name);',2000);
ajax.load('messages', 'content.php?'+name, true)
}
//-->
</script>";
echo "<BODY TOPMARGIN=0 LEFTMARGIN=0>";
echo "<div id='messages'></div>";
echo "<SCRIPT LANGUAGE='javascript'>refreshh(\"$query\");</SCRIPT>";
?>
my file that gets the text from the database (content.php )
PHP Code:
<?
include( "../inc/db.php" );
include( "../inc/cookieread.php" );
$quids = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker = $quids; include( "../inc/security.php" ); $quids = $checker;
$datas = explode("&", $quids);
$quids = $datas[0];
$result = mysql_query("SELECT * FROM im_messages WHERE fromm = '$username' AND too = '$quids' OR fromm = '$quids' AND too = '$username' ORDER BY ID");
while($row = mysql_fetch_array( $result )) {
echo $row[fromm] ." ". $row[message] ."<br>";
}
?>
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
|