| The Complete Shoutbox Tutorial |
pages (3): 1 2 [3] |
|
|
A simple
switch function has 4 or 5 cases, each of which are similar to using an
IF
statement. To put it simply, our switch checks which option the user
has chosen (i.e. add smilie, delete smilie, clear shoutbox,
logout,
nothing or posting) and then processes the correct code. The
add smilie and delete smilie options are the only two that need
further processing - the clear shoutbox and logout cases just handle
themselves in a line or two.
The add smilie case provides the user with a basic form to input the
original symbol i.e. =) or =O, and then a box to upload a replacement
smilie image. There are no dimension protections in our script, but we
should limit ourselves to images 15x15 pixels in size, or they will look
silly when displayed in the shoutbox text. Transparent GIF’s are a good
option, as they allow a whole multitude of different background
colours.
The delete smilie case provides the user with a list all of the current
smilies
and, when the user clicks one, the posting case authenticates the
click and deletes the appropriate smilie.
The posting case is based on the add smilie case. It first
authenticates that the user wants to upload a smilie, then defines the
directory to upload to, and uploads the file. It then puts the filename
into the ALT and URL fields in the database with the Symbol equal to the
symbol field on the form.
Emptying the shoutbox uses the SQL query: TRUNCATE TABLE [tablename] to
completely empty the table, removing all shouts in the
database in milliseconds.
if ( $_SESSION['admin_logged_in'] === 'true' )
{ |
Well… this just makes sure the user is logged in with
administrator permissions before continuing. Now we can finally get out
of functions and into the actual HTML of the page:
<html>
<head>
<title>Shoutbox Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Smilie administration: <a href="admin.php?mode=add">add smilie</a>
| <a href="admin.php?mode=delete">delete smilie</a></p>
<p>Shoutbox administration: <a href="admin.php?mode=clear">clear
shoutbox</a> | <a href="admin.php?mode=logout">logout</a></p>
<table width="600" border="1" cellpadding="5" bordercolor="#ccc">
<tr>
<td><?php selectAction($_GET['mode']); ?></td>
</tr>
</table>
</body>
</html> |
This is just basic HTML with a title,
some links and a content area that calls the selectAction function,
providing it with the URL variable ‘mode’. This page probably won't
validate through a HTML standards checker, but it is only meant as an
example anyway.
<?php
// showing login form
} else {
echo '
<form action="admin.php" method="post" name="login">
<input name="username" type="text" value="username" size="25"
maxlength="32"><br>
<input name="password" type="password" value="password" size="25"
maxlength="32"><br>
<input name="login" type="submit" value="login">
</form>
';
}
mysql_close($l);
?> |
This final snippet of code ensures that if the user isn’t logged in,
he/she will be given a nice login form to inwardly digest instead... Conclusion
Well, that’s pretty much everything! I hope you enjoyed reading this
walkthrough as much
as I enjoyed writing it (it took me HOURS as there are about 150 lines of
code in each file, then I had to write all this too, and the first beta
had a very stupid error in it that took me days to figure out... =P).
That said, I
hope this walkthrough has helped you in your quest for shoutbox-dom.
If you want to download these files in a completed format, just click
here
(.zip format). These files are 51% the property of
Averill.co.nz Web Development and
Robbie Averill and 49% the property of
BioRUST. If you use them on your website, please
show your appreciation by linking to us in return. If you don't,
we might have to remind you of the finer points of the GPL license under
which these files are offered... ;)
If you have any problems please don’t hesitate to contact me by clicking my name
below to visit my profile on the Forums, where you can Private
Message or E-mail me. My contact information is also on this page
if you don't want to register.
- Tutorial written by Scrowler
| 
|
|
|
great work :D
I just have one question; how can you separate the action, that you have in the .fla file, and have a separate .as file?
I always get stuck there, and I have to make a shoutbox for school, with a separate .as file..
is it hard? can you show me?
Thnx
Steffy |
Reply to this post |
User: Tamlin (#34751)
Date: Wed Nov 22, 2006. 00:25:26 | Post #2 of 3 |
|
Quote from flores741;34750: Nice work, but thought I might point out smilies is actually SMILES :D |
If you mean these things: :) :) :lol: :ciao:
I think you'll find that in 99.99999% of the web they are called Smilies, not Smiles. :nyanya:
Short for "Smiley Face", I assume. |
Reply to this post |
--- View Entire Thread ---
|

|
|
 |
TrentonCS Author: ahstanford Posted: Nov 06th, 7:40pm Activity: 3 replies, 27 views
|  | Html 5 Author: ahstanford Posted: Nov 05th, 1:32pm Activity: 5 replies, 89 views
|  | What are your favorite websites? Author: ahstanford Posted: Nov 05th, 12:51am Activity: 0 replies, 47 views
|  | What do you do for a living? Author: ahstanford Posted: Nov 04th, 11:04pm Activity: 0 replies, 44 views
|  | What is your favorite Subway sandwich? Author: ahstanford Posted: Nov 04th, 11:02pm Activity: 4 replies, 87 views
|  | Windows 7 Author: ahstanford Posted: Nov 04th, 10:59pm Activity: 0 replies, 48 views
|  | Google Wave Author: ahstanford Posted: Nov 04th, 10:52pm Activity: 0 replies, 59 views
|  | University Project Author: Gjbphp Posted: Nov 03rd, 8:59pm Activity: 1 replies, 90 views
|  | Hello BioRust! Author: ahstanford Posted: Nov 02nd, 5:39pm Activity: 4 replies, 87 views
|  | Illustrator cs4 - Convert outlines/graphics to ... Author: izidrew Posted: Oct 29th, 3:48pm Activity: 3 replies, 256 views
|  | Hello BioRust!! Author: MOST Posted: Oct 29th, 12:52am Activity: 4 replies, 144 views
|  | Hey! newbie Author: prelimiting Posted: Oct 28th, 11:51pm Activity: 1 replies, 113 views
|  |
|
 |
 |
 |
 |
 |
| --- Site Resources --- |
| Total Tutorials: | 212 |
| Total Downloads: | 415 |
| Linkbase Links: | |
 |
|
 |
 |
|