hi all, I have be charged with setting up a quick and dirty chat program. I have installed php, I found a chat php script, set it up, I did get past the Notice undefined veriables issue, now the only problem gett the script to post. when you hit submit nothing gets displayed.
here is the script:
<? // if name is not entered, present the form again if(!$chatname) { print_form(); exit; }; // do not post an empty message, unless it is a smiley $is_smile = "smileys/default.gif"; if(!$message && ($smile == $is_smile)) { print_form_nameset(); exit; }; // set up timestamp variables $time = date("H:i d/m"); $rightnow = time(); $lasttenmin = $rightnow - 600 ; // read data files into arrays $message_array = file("messages.htm"); $history_array = file("history.htm"); $online_array = file("online.txt"); // get the last 10 messages for ($counter = 1; $counter < 10; $counter++) { $old_messages .= $message_array[$counter]; } // get the last 200 messages from history for ($counter = 1; $counter < 200; $counter++) { $old_history .= $history_array[$counter]; } // stuff for the online things here foreach ($online_array as $user_on) { $fields = explode(",",$user_on); // if time stored is less than (older) than 10 mins ago, strip it out if( $fields[0] < $lasttenmin ){ break; } // if name stored is current chatname, strip it out if( $fields[1] == "$chatnamen" ){ break; } // otherwise put the data back into a nice package. $updated .= $user_on; } // record that we are online $updated .= "$rightnow,$chatnamen"; $online = stripslashes($updated); // then we need to write out the new online data file $open_file = fopen("online.txt", w); fputs($open_file, $online); fclose($open_file); // prepare the format of the new message $chatname = htmlspecialchars($chatname); $message = htmlspecialchars($message); $new_message = " $timen "; // set up header and footer for the messages and history page $header = "". "". "". "
". " n"; $footer = "
". ""; // write the new message file $open_file = fopen("messages.htm", "w"); fputs($open_file, $header); fputs($open_file, stripslashes($new_message)); fputs($open_file, $old_messages); fputs($open_file, $footer); fclose($open_file); // write the history file $open_file = fopen("history.htm", "w"); fputs($open_file, $header); fputs($open_file, stripslashes($new_message)); fputs($open_file, $old_history); fputs($open_file, $footer); fclose($open_file); // thats it for the main part, the functions follow print_form_nameset(); function print_form() { global $chatname; global $PHP_SELF; echo <<<FORM1
Screen Name :
Text Colour :
black
blue
yellow
red
green
White
Emotions :
Happy
Grin
Ha Ha
Yawn
Sleep
Angry
V Angry
Message :
FORM1;
}
function print_form_nameset()
{
global $myfont;
global $chatname;
global $PHP_SELF;
echo <<<FORM2
Screen Name : $chatname
Emotions :
Happy
Grin
Ha Ha
Yawn
Sleep
Angry
V Angry
Message :
FORM2;
}
?>