|  PHP Shoutbox help | 
| Author: | 
Message: | 
M73A 
Veteran Member 
     
  
  
  
Posts: 3212 Reputation: 37 
35 /   /   
Joined: Jul 2004 
 | 
| 
O.P.  PHP Shoutbox help
 i've got this script for a shoutbox off of hotscripts.. i just wondered if it was possible to have the php insert a new line (on the top of the .txt file) and put the new shouts ontop, so older ones are at the bottom. 
 
Its a simple script that adds whats entered into the text input bit onto the end of the .txt file.. 
 
any ideas? 
 
Thanks 
 
p.s. shall i post the code? 
 |   
 | 
| 06-08-2007 06:05 PM | 
 | 
  | 
vikke 
Senior Member 
    
  
  
 
Posts: 900 Reputation: 28 
32 /   /   
Joined: May 2006 
 | 
 RE: PHP Shoutbox help
I wish to see the code to understand what you mean.    
 |   
 | 
| 06-08-2007 06:14 PM | 
 | 
  | 
toddy 
Veteran Member 
     
  
  
kcus uoy
  
Posts: 2571 Reputation: 49 
– /   /   
Joined: Jun 2004 
 | 
| 
 RE: PHP Shoutbox help
 why would you want new shouts at the top??  
you'd have to have the input field at the top too, other wise u would mean that you'd have to view it on full window, or keep scrolling down to add new shouts. 
 This post was edited on 06-08-2007 at 06:24 PM by toddy.
 |   
 | 
| 06-08-2007 06:22 PM | 
 | 
  | 
M73A 
Veteran Member 
     
  
  
  
Posts: 3212 Reputation: 37 
35 /   /   
Joined: Jul 2004 
 | 
O.P.  RE: PHP Shoutbox help
quote: Originally posted by toddy 
why would you want new shouts at the top??  
you'd have to have the input field at the top too, other wise u would mean that you'd have to view it on full window, or keep scrolling down to add new shouts.
  yeah i managed to move the input field at the top too  
i want the new ones ontop so i dont have to keep clearing it if it gets to long, it will just scroll for ages but the newest ones will be on view   
heres the indexy one
 code: <html> 
<head> 
<link rel="stylesheet" type="text/css" href="style.css"> 
</head> 
 
<body style="overflow-x:hidden;overflow-y croll;"> 
 
<//------- Start copying from this point --------> 
 
<table class="shoutBox"> 
<tr><td class="shoutBox"> 
<p class="heading"><b>.:: ShoutBox ::.</b></p> 
<p> 
<center> 
<form name="shoutForm" method="POST" action="addShout.php"> 
Name: <input type="text" name="user" size="15"><br> 
Shout: <input type="text" name="shout" size="15"><br> 
<input type="submit" value="Send!"> 
</center> 
<hr> 
<?php  
 
  $fp = fopen("shouts.txt","r"); 
  while(($shout = fgetcsv($fp,1000,":")) !== FALSE) { 
    
     echo "<b>".$shout[0]." : </b>".$shout[1]."<br>"; 
  } 
 
  fclose($fp); 
?> 
</p> 
 
</form> 
</td></tr> 
</table> 
 
<//------- Finish copying from this point --------> 
 
</body> 
</html> 
  
And heres the 'Add shout.php' one
 code: <?php 
 
  /* ------------------------------------------------------- 
 
                           ShoutBox v1.1 
                     By: Mark Lethbridge, 2007 
 
     ------------------------------------------------------- 
 
     Install notes: 
     Only thing that needs to be changed in this file is the  
     line: $shoutbox_page = "index.php"; 
     You simple change "index.php" into the correct page 
     that the shoutbox will appear in. 
 
     -------------------------------------------------------- */ 
 
   $fp = fopen("shouts.txt","a"); 
   fwrite($fp,$_POST['user'].":".$_POST['shout']."\n"); 
   fclose($fp); 
   $shoutbox_page = "http://pps3.awardspace.com/Shoutbox/index.php"; 
   header("Location: $shoutbox_page"); 
 
?>
   
 |   
 | 
| 06-08-2007 06:33 PM | 
 | 
  | 
Nathan 
Veteran Member 
     
  
  
Yeah, "large dimensions" ;)
  
Posts: 2978 Reputation: 76 
– /   /   
Joined: Apr 2005 
 | 
| 
 RE: PHP Shoutbox help
 Why dont you just use a mysql one? 
 |   
 | 
| 06-08-2007 06:35 PM | 
 | 
  | 
M73A 
Veteran Member 
     
  
  
  
Posts: 3212 Reputation: 37 
35 /   /   
Joined: Jul 2004 
 | 
O.P.  RE: PHP Shoutbox help
quote: Originally posted by Napbree 
Why dont you just use a mysql one?
  free hosting account etc, didnt really want to use up the mysql database just for a shoutbox  
 |   
 | 
| 06-08-2007 06:37 PM | 
 | 
  | 
Nathan 
Veteran Member 
     
  
  
Yeah, "large dimensions" ;)
  
Posts: 2978 Reputation: 76 
– /   /   
Joined: Apr 2005 
 | 
| 
 RE: PHP Shoutbox help
 You would use 1 table in that database.  Not a big deal. 
 |   
 | 
| 06-08-2007 06:49 PM | 
 | 
  | 
M73A 
Veteran Member 
     
  
  
  
Posts: 3212 Reputation: 37 
35 /   /   
Joined: Jul 2004 
 | 
O.P.  RE: PHP Shoutbox help
quote: Originally posted by Napbree 
You would use 1 table in that database.  Not a big deal.
  well i still want to use this one so how can i make it new ontop    
 |   
 | 
| 06-08-2007 06:54 PM | 
 | 
  | 
Veggie 
Full Member 
   
  
  
 
Posts: 415 Reputation: 21 
38 /   /   
Joined: Sep 2004 
 | 
 RE: PHP Shoutbox help
code: <? 
$file='file.txt'; 
$newcontent = 'blah'; 
$new = $newcontent . "\n" . file_get_contents($file); 
$fp =fopen($file,'w'); 
fwrite($fp, $new); 
fclose($fp); 
 
?> 
  you cant use fopen to write to the top without over writing. Use this to get the file contents add it to the end of the new string then save
  
 This post was edited on 06-08-2007 at 07:13 PM by Veggie.
 |   
 | 
| 06-08-2007 07:13 PM | 
 | 
  | 
M73A 
Veteran Member 
     
  
  
  
Posts: 3212 Reputation: 37 
35 /   /   
Joined: Jul 2004 
 | 
O.P.  RE: PHP Shoutbox help
lol sorry, im a complete php newb... where about would it have to go, and in what one, lol 
quote: Originally posted by M73A 
s the 'Add shout.php' one 
 
    code: 
    <?php 
 
      /* ------------------------------------------------------- 
 
                               ShoutBox v1.1 
                         By: Mark Lethbridge, 2007 
 
         ------------------------------------------------------- 
 
         Install notes: 
         Only thing that needs to be changed in this file is the 
         line: $shoutbox_page = "index.php"; 
         You simple change "index.php" into the correct page 
         that the shoutbox will appear in. 
 
         -------------------------------------------------------- */ 
 
$file='file.txt'; 
$newcontent = 'blah'; 
$new = $newcontent . "\n" . file_get_contents($file); 
$fp =fopen($file,'w'); 
fwrite($fp, $new); 
fclose($fp); 
 
       fwrite($fp,$_POST['user'].":".$_POST['shout']."\n"); 
       fclose($fp); 
       $shoutbox_page = "http://pps3.awardspace.com/Shoutbox/index.php"; 
       header("Location: $shoutbox_page"); 
 
    ?> 
 
 
 
 
 
 
----------->Click Here To Sign Up To Nintendo.com VIP<-----------
  
like that?  
 This post was edited on 06-08-2007 at 07:15 PM by M73A.
 |   
 | 
| 06-08-2007 07:14 PM | 
 | 
  | 
| 
Pages: (4): 
« First
  
 [ 1 ]
 2
 3
 4
 
»
 
Last »
 | 
| 
 |