Jump to content

[SOLVED] Mini-chat script


empty

Recommended Posts

hi all could any one help me and tell me what's wrong in this script I don't get it I am looking at it from 2 weeks and I couldn't find the mistake

<html>
<head>
<title>Chat</title>
</head>

<body>
<h1>Chat</h1>
<form method="post">
Login:
<input type="text"name="login" size="20" maxlength="20">;
<?php 
value "$login"
<lt><br> <gt></lt></br> </gt>;
Message:
<input type="text" name="message" size="35" maxlength="255">
<input type="submit" name="send" value="Send";
<lt><br> <gt></lt></br> </gt>;
</form>
?>

<?php

include("inc_connect.php";


function addMessage( $login, $message ) {
$login = mysql_real_escape_string(strip_tags( $login ));
$message = mysql_real_escape_string(strip_tags( $message, <lt><gt></lt></gt><lt><gt></lt></gt>));
$itstime = date("H:i:s");
mysql_query( "INSERT INTO minichat ( login, message, itstime )
VALUES ( '$login','$message', '$itstime' )");
}

if ( isset( $_POST['send'] )) {
if ( $login == '' ) {
echo span style="color:red";
.('Hey, what\'s your name anyway?')
. &quot;&lt;/span&gt;&lt;br /&gt;&quot;;
}
elseif ( $message == '' ) {
echo &quot;&lt;span style=\&quot;color:red\&quot;&gt;&quot;
.('Say something or shout it out! Uhm ... no, type it in!')
. &quot;&lt;/span&gt;&lt;br /&gt;&quot;;
}
else {
addMessage( $_POST['login'], $_POST['message'], $_POST['itstime'] );
}
}

function printMessages() {
//ORDER BY id DESC LIMIT 0,10: Biggest id first, so newest message first
$rs = mysql_query( &quot;SELECT * FROM minichat ORDER BY id DESC LIMIT 0,10&quot; );
while ( $msg = mysql_fetch_array( $rs )) {

$msg['message']=wordwrap($msg['message'], 75, 
echo span style="color:blue"<gt>;
. $msg['login']
. &quot; (&quot;
. $msg['itstime']
. &quot;)span style="color:navy";
}
}
printMessages();
mysql_close($db);
?>
</body>
</html>

 

and there is the other file

<?php
$db = mysql_connect("localhost","root","password")
or die ("Connection failed!");
mysql_select_db("minichat");
?>

Link to comment
https://forums.phpfreaks.com/topic/50271-solved-mini-chat-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.