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

|
|
 |
cleaning up/ coloring Author: ratsliveon Posted: Jul 05th, 3:14am Activity: 3 replies, 99 views
|  | My dog is sick ;_; Author: Firefly Posted: Jul 04th, 9:08pm Activity: 6 replies, 109 views
|  | pride 08 boston part 2 Author: automaton2 Posted: Jul 03rd, 7:51pm Activity: 0 replies, 115 views
|  | Jero is here Author: Jero Posted: Jul 03rd, 7:18pm Activity: 2 replies, 87 views
|  | The Epic Author: unleash Posted: Jul 03rd, 12:17am Activity: 9 replies, 160 views
|  | Just wanted to say Hello~ ^.^ Author: Firefly Posted: Jul 02nd, 8:50pm Activity: 5 replies, 115 views
|  | Is it possible to save dynamic text in Flash as... Author: RTs Posted: Jul 02nd, 9:55am Activity: 1 replies, 144 views
|  | Jamukha, Got Milk? (Vector Illustration) Author: gigsmella Posted: Jul 02nd, 9:23am Activity: 0 replies, 135 views
|  |
|
 |
 |
 |
 |
 |
| --- Site Resources --- |
| Total Tutorials: | 210 |
| Total Downloads: | 406 |
| Linkbase Links: | 255 |
 |
|
 |
 |
|