Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Make A Flat Based Shoutbox, With Auto Refresh.
lailai
post Apr 7 2008, 09:38 AM
Post #1


Newbie [Level 3]
***

Group: Members
Posts: 45
Joined: 8-December 07
Member No.: 54,414



With this tutorial, you will learn how to create a simple shoutbox, but only uses a .txt file. Also with auto refresh, and I am going to do a backgound.
We will be making 5 files.
1. index.php The main page
2. msg.php Reading msg.txt
3. msg.txt Note: You must give it 777
4. shout.php Where it add to msg.txt
5. bg.gif Background.

Index.php would be like this:
CODE
<html>
<head>
<title>Shoutbox</title>
</head>
<body>
<iframe src="msg.php" marginwidth="1" marginheight="0" height="200"width="153" border="0" frameborder="0"></iframe>
<FORM name="shout" action="shout.php" method="POST">
Name:<br>
<INPUT TYPE="TEXT" name="name" size="20"><br>
Message:<br>
<INPUT TYPE="TEXT" name="message" size="20"><br>
<br>
<INPUT TYPE="Submit" name="submit" value="Shout!" size="20">
</FORM>
</body>
</html>

Let's go over what the code do.
<html> -> <body> are just the title.
<iframe> gets msg.php which gets msg.txt. You will know why I do that later.
<FORM> -> </FORM> is where you can type what you want to shout.

Now let's make the msg.php!
CODE
<html>
<head>
<meta http-equiv="refresh" content="8;url=msg.php" />
</head>
<body>
<?php include('msg.txt'); ?>
</body>
</html>

I shouldn't really explan this.
Meta refresh the page every 8 sec.
<?php include gets msg.txt.

I did this was for it won't refresh the whole page, as if it refresh while typing it will rub out the msg.

Just make a msg.txt with 777.

And for shout.php:
CODE
<?php

$name = $_POST['name'];
$message = $_POST['message'];

$code = array(
'/:\)/',
'/:P/',
'/:D/'
//Bla bla bla
);

$image = array(
'<img src="smileys/1.gif">',
'<img src="smileys/2.gif">',
'<img src="smileys/3.gif">'
// Bla bla bla
);
$formatted = preg_replace($code, $image, $message);

$tag = ("<font size=\"2\" face=\"Arial\"><b>
$name:</b>$message
</font><br>");

$read = fopen("content.txt", "r");
$contents = fread($read, filesize('content.txt'));
fclose($read);
$write = fopen("content.txt", "w");
fwrite($write, "$tag $contents");
fclose($write);

print "<meta http-equiv=\"refresh\" content=\"0;index.php\">";

?>


I made a little smiley feature, and you can use it for bb codes like [heading] turns to <h2> and stuff.
Hope you enjoyed the tut!
Go to the top of the page
 
+Quote Post
datanizze
post Jun 8 2008, 08:14 PM
Post #2


Newbie
*

Group: Members
Posts: 7
Joined: 8-June 08
Member No.: 63,355



OMFG, this was so helful, Even without any PHP-programming skills, I managed to add some new smilieys and get it to work according to my wishes tongue.gif, very easy-to-understand tutorial with fast result.

only problem I had was that there was no space between two posts. however, I managed to fix this, but it was not in any of these files frome this tutorial, i got to change css-files, create new css-files and edit some other HTML-code.

Once again, GREAT tutorial! you made my understanding for PHP bigger now too....

but there is ONE thing. how do I make a check so that the user did type in a message, so i don't get empty messages (SPAM)??

This post has been edited by datanizze: Jun 8 2008, 08:28 PM
Go to the top of the page
 
+Quote Post
StaticIp
post Jun 17 2008, 03:59 AM
Post #3


Newbie [Level 1]
*

Group: [HOSTED]
Posts: 12
Joined: 17-June 08
From: Aurora, Colorado
Member No.: 63,742



My browser tries to save the .php file every time I press shout
Go to the top of the page
 
+Quote Post
nitish
post Jun 21 2008, 07:38 AM
Post #4


Newbie [Level 2]
**

Group: [HOSTED]
Posts: 35
Joined: 19-September 06
From: Higara
Member No.: 30,215



QUOTE(StaticIp @ Jun 17 2008, 09:29 AM) *
My browser tries to save the .php file every time I press shout


You are probably running it from your computer without php installed. You can download software like Easy PHP, WAMP. Just search them on google.
Then copy those files to something like www or htdocs in the installation folder and run the server.
Go to the top of the page
 
+Quote Post
minimcmonkey
post Jun 25 2008, 09:44 PM
Post #5


Premium Member
********

Group: [HOSTED]
Posts: 151
Joined: 19-June 08
From: United Kingdom - Cornwall!!!!!
Member No.: 63,876



Nice tutorial, havent used it yet, but i must! as i havent done any PHP for a long time, and intend to do some more before i start creating my new website!

Nice thread!
Go to the top of the page
 
+Quote Post
Forbez
post Jun 25 2008, 10:43 PM
Post #6


Privileged Member
*********

Group: [HOSTED]
Posts: 603
Joined: 13-December 06
Member No.: 35,271



Nice and simple, I love it. You really put a lot of care into this tutorial. Well done mate. I may be using this myself sometime.

Perhaps you could post some suggested different CSS styles for this.
Go to the top of the page
 
+Quote Post
lailai
post Jul 21 2008, 09:46 AM
Post #7


Newbie [Level 3]
***

Group: Members
Posts: 45
Joined: 8-December 07
Member No.: 54,414



Thanks guys. Some guy has stole my tut, so I need to get that fixed before posting more tuts here.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Key Logger.(36)
  2. Making Money Creating Logo's(19)
  3. A Pretty Good Easy Way To Make Some Money(21)
  4. Make Your Own Mmorpg(41)
  5. How To Make A Web Browser(49)
  6. Do You Use (or Plan To) Asp.net?(8)
  7. How Do I Make Gold Fast In Runescape/(126)
  8. How Do I Make A Website(20)
  9. Make Money Online!(17)
  10. Make Calls From The Internet?(8)
  11. Best Ways To Make Money In Runescape(12)
  12. How To Make A Counter Strike 1.6 Dedicated Server(16)
  13. Runescape Private Server(69)
  14. The Earth Is Really Flat(107)
  15. How To Get A Girl That Has Refused You(12)
  1. What Kind Of Car Do You Have?(26)
  2. Help Creating A Profile Website(13)
  3. Budding Java Game Developers?(9)
  4. How To Make A Website ?(11)
  5. How To Make Your Own Counter Strike Source Dedicated Server!(34)
  6. Paypal(10)
  7. Grand Theft Auto Iv Announced For The Pc!(5)
  8. Web Based Os(7)
  9. How To Install Opengeu In Ubuntu(0)
  10. Make Free Money Online(2)
  11. How To Make Image Buttons Act As Submit Button(8)
  12. Why Is The Shoutbox Time Wrong?(10)
  13. Make An Extra $50 Or More Per Day!(5)


 



-