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');

 

?>

 

 

 

Link to comment
Share on other sites

<?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');

?>

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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>

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.