Hi all, i found this code on the internet for a message board which does not require a database so i followed all the instructions and uploaded it here: http://themepics.co.uk/php-forum-test/
However,when i try to open the files it tries to make me download them rather than opening them in the browser. Iv checked my domain and it is not set to have php* files as downloads. Can any1 tell me why? the code i used is below
<!-- needs three files chat.php3, thread.php3 and messages.txt -->
<!-- start of chat.php3 -->
<?php
//
// A php only message board. All source written by Ian Hickman. Aug 2000. Use with thread.php3 and message.txt Feel free to use this. open message file //
$message_array = file( "messages.txt" );
$number_of_threads=0;
list( $fnumber, $fsubject, $fname, $femail, $fdate, $ftext, $flinkurl, $flinktitle, ) = split("::", $message_array[0] );
if( $name!="" && $subject!="" && $message!="" && ( $name!=$fname || $subject!=$fsubject ) ){
for( $counter=0; $counter<100; $counter++ ){
if( $message_array[$counter] ){
list( $pnumber, $psubject, $pname, $pemail, $pdate, $ptext, $plinkurl, $plinktitle ) = split("::", $message_array[$counter] );
if( $pnumber && $psubject && $ptext && $pname ){
if( $pnumber > $number_of_threads ){
$number_of_threads=intval($pnumber);
}
$old_messages .= $message_array[$counter];
}
}
}
$date=date("H:i:s d/m/y");
$message=ereg_replace( "\n", "<br>", $message );
$new_message = ($number_of_threads+1)."::$subject::$name::$email::$date::$message";
$new_message = htmlspecialchars( $new_message );
if( $linkurl && !(ereg( "http:\/\/", $linkurl )) ){
$linkurl = "http://".$linkurl;
}
$new_message .= "::$linkurl::$linktitle\n";
$open_file = fopen( "messages.txt", "w");
fputs($open_file, stripslashes( $new_message ));
fputs($open_file, $old_messages);
fclose($open_file);
}
$indent=0;
$message_array = file( "messages.txt" );
for( $counter=0; $counter<100; $counter++ ){
list( $pnumber, $psubject, $pname, $pemail, $pdate, $ptext ) = split("::", $message_array[$counter] );
// check that it is valid, should be due to validy check on message post
if( $pnumber && $psubject && $ptext && $pname ){
// indent if message is a reply
if( intval($pnumber)!=$pnumber && $indent==0){
$print_titles .= "<ul>\n";
$indent=1;
}
if( intval($pnumber)==$pnumber && $indent==1){
$print_titles .= "</ul>\n";
$indent=0;
}
// add the titles to the print_titles string
$print_titles .= "<li><a href=\"thread.php3#$pnumber?thread=$pnumber\">$psubject</a> ";
// if an email address is supplied link to it
if( $pemail ){
$print_titles .= "- <a href=\"mailto:$pemail\">$pname</a> $pdate\n";
} else {
$print_titles .= "- $pname $pdate\n";
}
}
}
// print the title array
echo( "<ul>\n" );
echo( $print_titles );
echo( "</ul>\n" );
// check that there are no lists open
if( $indent==1 ){
echo( "</ul>\n" );
}
?>
<hr>
<form action="chat.php3" method="post">
<table border="0">
<tr>
<td>Name : </td>
<td><input size="50" type="text" name="name"></td>
</tr>
<tr>
<td>Email (Optional) : </td>
<td><input size="50" type="text" name="email"></td>
</tr>
<tr>
<td>Subject : </td>
<td><input size="50" type="text" name="subject"></td>
</tr>
<tr>
<td>Message : </td>
<td><textarea cols=55 rows=10 name="message" wrap="virtual"></textarea></td>
</tr>
<tr>
<td>Link URL (Optional) : </td>
<td><input size="50" type="text" name="linkurl"></td>
</tr>
<tr>
<td>Link Title (Optional) : </td>
<td><input size="50" type="text" name="linktitle"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Post new message"><input type="reset"></td>
</tr>
</table>
<!--end of chat.php3-->
<!--start of thread.php3-->
<?php
// A php only message board. //
// All source written by Ian Hickman. Aug 2000. //
// Use with chat.php3 and message.txt //
// Feel free to use this. //
// open message file
$message_array = file( "messages.txt" );
$threadnumber=0;
// store the last entry to avoid duplicates
list( $fnumber, $fsubject, $fname, $femail, $fdate, $ftext, $flinkurl, $flinktitle ) = split("::", $message_array[0] );
// if something has been entered and it is not the same as the last one
if( $name!="" && $subject!="" && $message!="" && ( $name!=$fname || $subject!=$fsubject ) ){
// loop through all old messages
for( $counter=0; $counter<100; $counter++ ){
// check message line exists
if( $message_array[$counter] ){
// split message field up
list( $pnumber, $psubject, $pname, $pemail, $pdate, $ptext, $flinkurl, $flinktitle ) = split("::", $message_array[$counter] );
// check for validy of message field. Should be valid as messages entered are validated
if( $pnumber && $psubject && $ptext && $pname ){
// find out where to put the new message
if( intval($pnumber) < $thread ){
$old_messages .= $message_array[$counter];
}
if( intval($pnumber) == $thread ){
$messages_after .= $message_array[$counter];
$threadnumber=$pnumber+0.01;
}
if( intval($pnumber) > $thread ){
$messages_after .= $message_array[$counter];
}
}
}
}
// create new message
$date=date("H:i:s d/m/y");
$message=ereg_replace( "\n", "<br>", $message );
$new_message = "$threadnumber::$subject::$name::$email::$date::$message";
// strip html chars
$new_message = htmlspecialchars( $new_message );
if( $linkurl && !(ereg( "http:\/\/", $linkurl )) ){
$linkurl = "http://".$linkurl;
}
$new_message .= "::$linkurl::$linktitle\n";
// open message file
$open_file = fopen( "messages.txt", "w");
// strip html stuff and add message to file
fputs($open_file, $messages_after);
fputs($open_file, stripslashes( $new_message ));
fputs($open_file, $old_messages);
fclose($open_file);
}
// loop through all messages copying the title and messages into separate arrays
$message_array = file( "messages.txt" );
for( $counter=0; $counter<100; $counter++ ){
// split the message field
list( $pnumber, $psubject, $pname, $pemail, $pdate, $ptext, $plinkurl, $plinktitle ) = split("::", $message_array[$counter] );
// check that it is valid although it should be due to earlier validity checks
// also check to see if the message is the thread (or followup) that we want
if( intval($pnumber)==intval($thread) && $psubject && $ptext && $pname ){
// add the message to print_messages string
$print_messages .= "<h3><a name=$pnumber>$psubject</a></h3>\n";
// if an email address is supplied link to it
if( $pemail ){
$print_messages .= "<p>Posted by <a href=\"mailto:$pemail\">$pname</a> on $pdate</p>\n<p>$ptext</p>";
} else {
$print_messages .= "<p>Posted by $pname on $pdate</p>\n<p>$ptext</p>";
}
// if a url has been submitted draw it up
if( $plinkurl && $plinktitle ){
$print_messages .= "<p><a href=\"$plinkurl\" target=\"_blank\">$plinktitle</a></p>\n";
} else {
$print_messages .= "\n";
}
}
}
// print the messages
echo( $print_messages );
?>
<hr>
<form action="thread.php3" method="post">
<?php
// pass the thread value when submitted
echo( "<input type=\"hidden\" name=\"thread\" value=\"$thread\">\n" );
?>
<table border="0">
<tr>
<td>Name : </td>
<td><input size="50" type="text" name="name"></td>
</tr>
<tr>
<td>Email (Optional) : </td>
<td><input size="50" type="text" name="email"></td>
</tr>
<tr>
<td>Subject : </td>
<td><input size="50" type="text" name="subject"></td>
</tr>
<tr>
<td>Message : </td>
<td><textarea cols=55 rows=10 name="message" wrap="virtual"></textarea></td>
</tr>
<tr>
<td>Link URL (Optional) : </td>
<td><input size="50" type="text" name="linkurl"></td>
</tr>
<tr>
<td>Link Title (Optional) : </td>
<td><input size="50" type="text" name="linktitle"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Post Followup"><input type="reset"></td>
</tr>
</table>
<hr>
<center>
[ <a href="chat.php3">Main Board</a> ]
</center>
<hr>
<!--end of thread.php3-->
<!--all of messages.txt should be on one line-->
<!--start of messages.txt-->
1::Greets::Ian::ian@neverin.com::12:40:23 04/08/00::Hello from Ian, thankyou for using my message board::[url]http://www.neverin.com::neverin[/url]
<!--end of messages.txt-->
[RESOLVED] I need help getting this message board to work!
Try change all references of php3 to php and rename the files so they have .php extensions instead of .php3
Thanks a lot that got the form working and up on the website but it isnt showing any messages. If you need me to re-post the code just say, and these are the links for everything iv uploaded with the php message bullitin thing:
http://themepics.co.uk/php-forum-test/index.htm
Oh and also, for when its completely fixed, how do i mark a post as resolved?
Thanks a lot
Max.
There doesn't seem to be any code to output the message from what I can see.
Can you provide a link to the site where you got this code from and I'll take a look
I've added more instructions on marking threads resolved in my sig
hi, last time i check jus after i found that the message was not shown, i went onto the website and the code i put in the 1st message in the thread was pretty much all it had, apart from a few more notes (ones that people could read but the browser would ignore) but i took them out to reach the 1000 word limit but there was no information pack or anything. Does anybody know were i can get a message board or forum which does not require a database and instead saves the posts in a text file or somthing for free? Or is there an easy way to getting the messages from the forms which i have already made (see my last post) and then loading them on the page?
Thanks,
Max
I wouldn't use a message board without a database personally.
I used to use an upload script which stored the file details such as filesize and description etc. in a text file. This proved to be unstable in some cases which lines from the file disappearing.
ok well im not really that bothered about a few glitches cos its only somthing for friends to use really. Do you have the code saved somwere so i can use it? or know of anywere were i can get a databaseless forum? xD Thanks a lot
Max
Do you want the file upload script now..........I can email it to you if you PM me your email address.
excellant thanks! iv pm'd you but im not entirely sure it went through. i think it did because i tried again but it said no new messages before 60 seconds. Thanks again!!
Max
Got it and replied