Jump to content

[SOLVED] Automatically disconnect or disable a PHP message board - pliz help


worldcomingtoanend

Recommended Posts

I have the following simple message board script and how can I automatically disconnect it , lets say after 10 people have entered their comments. Thank you for your help: <form>

<input type="text" name="message"><br />

<input type="submit">

</form>

 

<?php

 

if (isset($_GET['message']))

{

    $fp = fopen('./messages.txt', 'a');

    fwrite($fp, "{$_GET['message']}<br />");

    fclose($fp);

}

 

readfile('./messages.txt');

 

?>

 

 

 

<?php

if (isset($_GET['message']))
{
    $count = fopen('./messageCount.txt','r+');
    $n = fread($count,1024);
    if (($e = ($n + 1)) <= 10) {
        rewind($count);
        fwrite($count,$e);
        fclose($count);
        $fp = fopen('./messages.txt', 'a');
        fwrite($fp, "{$_GET['message']}<br />");
        fclose($fp);
    }
}

readfile('./messages.txt');

?>

<?php

if (isset($_GET['message']))
{
    $count = fopen('./messageCount.txt','r+');
    $n = fread($count,1024);
    if (($e = ($n + 1)) <= 10) {
        rewind($count);
        fwrite($count,$e);
        fclose($count);
        $fp = fopen('./messages.txt', 'a');
        fwrite($fp, "{$_GET['message']}<br />");
        fclose($fp);
    }
}

readfile('./messages.txt');

?>

 

hie RusselL thanks for your help.  I hv tried it but it doesnt seem to do anything. i can even eneter more than 10, 15, ,etc.  i dont know where i am going wrong.

http://lovinglori.com/message.php

 

<?php
// messages.php
if (isset($_POST['message'])) {
if (file_exists('messageCount.txt')) {
	$count = fopen('messageCount.txt','r+');
	$n = fread($count,1024);
}
else {
	$count = fopen('messageCount.txt','a+');
	$n = 0;
}
if (($e = ($n + 1)) <= 10) {
	rewind($count);
	fwrite($count,$e);
	fclose($count);
	$fp = fopen('messages.txt', 'a');
	fwrite($fp, "{$_POST['message']}<br />");
	fclose($fp);
}
}
readfile('messages.txt');
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
<input type="text" name="message">
<input type="submit" value="SUBMIT">
</form>

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.