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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.