PDA

View Full Version : Simple PHP/MySql/Flash App.


brendanww
05-17-2005, 12:56 AM
I made this about a month ago, so please don't make fun of me for its crappy coding, just thought I'd share how I did it

sendchat.php

<?php
$message = $_POST['damessage'];
$sender = $_POST['dasender'];
$connect = mysql_connect("*******", "******", "*****");
mysql_select_db("*********", $connect);
$query = "INSERT INTO chat_test (user, message) VALUES ('$sender', '$message')";
mysql_query($query);
?>


loadme.php

<?php
$connect = mysql_connect("****", "******", "******");
mysql_select_db("*******", $connect);
$id = $_POST['id'];
$id++;
$query = mysql_query("SELECT * FROM chat_test WHERE id='$id'");
$numcold = mysql_num_rows($query);
if($numcold == "0")
{
$chill = "yes";
}
else
{
$chill = "no";
}
$fetchit = mysql_fetch_array($query);
$message = "$fetchit[message]<br>";
echo "&retm=$message&retu=$fetchit[user]&reti=$fetchit[id]&retc=$chill";
?>


checkid.php

<?php
$connect = mysql_connect("******", "******", "******");
mysql_select_db("*******", $connect);
$query = mysql_query("SELECT * FROM chat_test ORDER BY id DESC LIMIT 0, 1");
$fetchthis = mysql_fetch_array($query);
echo "&lastid=$fetchthis[id]";
?>


here is fla...http://www.mad-host.net/chat.fla

MySql Table chat_test
id int(11) No auto_increment
user varchar(255) No
message varchar(255) No

you can also use LONGTEXT for message so peeps can make longer messages. I set this page up so that a friend of mine could talk to me online (his parents dont want him downloading instant messenger programs), and therefore there isnt much security (no eregi's or preg's checking for formatting), i wouldnt recommend using this either as it could be much faster and there are lots of things that i'd change if i had time to.

creativeforces
07-15-2006, 07:43 AM
This is great, I have been looking all oer for somthing like this, but the link to your fla doesn't work anymore...Is it still available for download.