I have found this nice tutorial on building a minichat module.
I manage to add the entries into the database, but somehow my
"function printMessages()" doesn't want to work.
I can't find anything in my phpinfo that refers that it's not activated.
Can anyone see why it wouldn't print?
Here is my code:
<html>
<form method="post"><br>
Login:<input type="text" name="login" size="6"><br>
Message:<input type="text" name="message" size="20"><br>
<input type="submit" value="Send"><br>
</form>
</html>
<?php
function addMessage( $login, $message )
{
$conn= mysql_connect( "localhost", "user", "password" );
$sql = mysql_select_db( "mydatabase" );
$login = mysql_escape_string( strip_tags( $login ) );
$message = mysql_escape_string( strip_tags( $message, '<a><b><i><u>') );
mysql_query ("INSERT INTO MINICHAT ( ITSTIME, LOGIN, MESSAGE ) VALUES ( '".time()."', '".$login."','".$message."') ");
}
if ( isset( $_POST['message'] )) {
addMessage( $_POST['login'], $_POST['message'] );
}
if ( isset( $_POST['message'] ))
{
function printMessages()
{
echo "567";
$rs = mysql_query( "SELECT * FROM MESSAGE ORDER BY ITSTIME" )
or die ("ERROR2");
while ( $msg = mysql_fetch_array( $rs ))
{
echo date( 'h:m', $msg['ITSTIME'] )." ".$msg['LOGIN'].">".$msg['MESSAGE']."<br>";
echo $message['login']." >".$message['message']."<br>";
}
}
echo "end";
}
?>