worldcomingtoanend Posted January 7, 2009 Share Posted January 7, 2009 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 https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/ Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 <?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 https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731509 Share on other sites More sharing options...
worldcomingtoanend Posted January 7, 2009 Author Share Posted January 7, 2009 <?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 https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731516 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 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 https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731547 Share on other sites More sharing options...
worldcomingtoanend Posted January 7, 2009 Author Share Posted January 7, 2009 http://lovinglori.com/message.php hey Russell, Thanks very much it worked this time. You deserve a sweet year. take care Link to comment https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731561 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 you too bro Link to comment https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731562 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 oh and.. please click 'solved' at the bottom.. that way people don't still reply to this and it fills my "REPLIES TO YOUR POST" box thingy Link to comment https://forums.phpfreaks.com/topic/139828-solved-automatically-disconnect-or-disable-a-php-message-board-pliz-help/#findComment-731563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.