“shout!box.php”
CODE
<html>
<head>
<title> Projekt Shout!box </title>
</head>
<body>
<form action="shout!box_prc.php" method="post">
<table border="2" align="center" width="400">
<tr>
<td align="center">SHOUT!!!BOX</td>
</tr>
<tr height="300">
<td align="center" width="300" >
<table border="1">
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data order by id desc";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);$count=0;
do
{
echo $fetch['id']."-".$fetch['sender'].": ".$fetch['message']."<br>";
$count++;
} while (($fetch=mysql_fetch_array($db_query)) && ($count<10));
}
else
{
echo "Connection failed";
}
mysql_close($connection)
?>
</table>
</td>
</tr>
<tr>
<td align="center">
Sender:<input type="text" name="sender">
</td>
</tr>
<tr>
<td align="center">
Message:<input type="memo" name="message">
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
<head>
<title> Projekt Shout!box </title>
</head>
<body>
<form action="shout!box_prc.php" method="post">
<table border="2" align="center" width="400">
<tr>
<td align="center">SHOUT!!!BOX</td>
</tr>
<tr height="300">
<td align="center" width="300" >
<table border="1">
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data order by id desc";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);$count=0;
do
{
echo $fetch['id']."-".$fetch['sender'].": ".$fetch['message']."<br>";
$count++;
} while (($fetch=mysql_fetch_array($db_query)) && ($count<10));
}
else
{
echo "Connection failed";
}
mysql_close($connection)
?>
</table>
</td>
</tr>
<tr>
<td align="center">
Sender:<input type="text" name="sender">
</td>
</tr>
<tr>
<td align="center">
Message:<input type="memo" name="message">
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
“shout!box_prc.php”
CODE
<html>
<title>Processing...</title>
</html>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$_POST[sender] =strip_tags($_POST[sender] ,"<b><i><u>");
$_POST[message]=strip_tags($_POST[message],"<b><i><u>");
$db="shoutbox";
$query="insert into data(sender,message) values('$_POST[sender]','$_POST[message]')";
$insert=mysql_db_query($db,$query);
if ($insert) echo "Success";
else echo "Failed to insert";
echo "<a href='shout!box.php'>Return</a>";
}
mysql_close($connection);
?>
<title>Processing...</title>
</html>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$_POST[sender] =strip_tags($_POST[sender] ,"<b><i><u>");
$_POST[message]=strip_tags($_POST[message],"<b><i><u>");
$db="shoutbox";
$query="insert into data(sender,message) values('$_POST[sender]','$_POST[message]')";
$insert=mysql_db_query($db,$query);
if ($insert) echo "Success";
else echo "Failed to insert";
echo "<a href='shout!box.php'>Return</a>";
}
mysql_close($connection);
?>
“shout!box_adm.php”
CODE
<title>Admin Page</title>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data order by id asc";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);
do
{
echo $fetch['id']."-".$fetch['sender'].": ".$fetch['message'];
echo "<a href=shout!box_edt.php?code=$fetch[id]> Edit</a>"." "."<a href=shout!box_del.php?code=$fetch[id]>Delete</a>"."<br>";
} while ($fetch=mysql_fetch_array($db_query));
}
mysql_close($connection);
?>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data order by id asc";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);
do
{
echo $fetch['id']."-".$fetch['sender'].": ".$fetch['message'];
echo "<a href=shout!box_edt.php?code=$fetch[id]> Edit</a>"." "."<a href=shout!box_del.php?code=$fetch[id]>Delete</a>"."<br>";
} while ($fetch=mysql_fetch_array($db_query));
}
mysql_close($connection);
?>
“shout!box_del.php”
CODE
<title>Deletion</title>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="delete from data where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
if($db_query) echo "Deleted succesfully";
else echo "Failed";
echo "<a href=shout!box_adm.php>Return</a>";
}
mysql_close($connection);
?>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="delete from data where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
if($db_query) echo "Deleted succesfully";
else echo "Failed";
echo "<a href=shout!box_adm.php>Return</a>";
}
mysql_close($connection);
?>
“shout!box_edt.php”
CODE
<title>Deletion</title>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);
echo "<form action=shout!box_edt2.php?code=$_GET[code] method=post>";
echo "<b>Update</b>:<br>
Old:".$fetch[sender]."<br>
New: <input type=text name=sender2><br><br>
Old:".$fetch[message]."<br>
New: <input type=text name=message2><br><br>
<input type=submit value=Update>";
echo "</form>";
}
mysql_close($connection);
?>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$db="shoutbox";
$query="select * from data where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
$fetch=mysql_fetch_array($db_query);
echo "<form action=shout!box_edt2.php?code=$_GET[code] method=post>";
echo "<b>Update</b>:<br>
Old:".$fetch[sender]."<br>
New: <input type=text name=sender2><br><br>
Old:".$fetch[message]."<br>
New: <input type=text name=message2><br><br>
<input type=submit value=Update>";
echo "</form>";
}
mysql_close($connection);
?>
“shout!box_edt2.php”
CODE
<title>Edit</title>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$_POST[sender2] =strip_tags($_POST[sender2] ,"<b><i><u>");
$_POST[message2]=strip_tags($_POST[message2],"<b><i><u>");
echo $_POST[sender2];
$db="shoutbox";
$query="update data set sender='$_POST[sender2]', message='$_POST[message2]' where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
if($db_query) echo "Update Succesful";
else echo "Failed";
echo "<a href=shout!box_adm.php>Return</a>";
}
mysql_close($connection);
?>
<?php
$connection=mysql_connect("localhost","root","");
if($connection)
{
$_POST[sender2] =strip_tags($_POST[sender2] ,"<b><i><u>");
$_POST[message2]=strip_tags($_POST[message2],"<b><i><u>");
echo $_POST[sender2];
$db="shoutbox";
$query="update data set sender='$_POST[sender2]', message='$_POST[message2]' where id=$_GET[code]";
$db_query=mysql_db_query($db,$query);
if($db_query) echo "Update Succesful";
else echo "Failed";
echo "<a href=shout!box_adm.php>Return</a>";
}
mysql_close($connection);
?>
“SQL Query”
CODE
CREATE DATABASE `shoutbox`;
USE shoutbox;
CREATE TABLE `data` (
`id` int(10) NOT NULL auto_increment,
`sender` varchar(30) NOT NULL default '',
`message` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Data for shoutbox' AUTO_INCREMENT=13;
INSERT INTO `data` VALUES (1, 'DivL', 'Hello');
INSERT INTO `data` VALUES (2, 'DivL', 'Alo');
INSERT INTO `data` VALUES (3, 'Alo', ' juga');
INSERT INTO `data` VALUES (4, 'fd', 'fd');
INSERT INTO `data` VALUES (5, 'w', 's');
INSERT INTO `data` VALUES (6, 'w', 'f');
INSERT INTO `data` VALUES (7, 'e', 'f');
INSERT INTO `data` VALUES (8, 'e', 'fd');
INSERT INTO `data` VALUES (9, 'e', 'e');
INSERT INTO `data` VALUES (10, 'g', 'g');
USE shoutbox;
CREATE TABLE `data` (
`id` int(10) NOT NULL auto_increment,
`sender` varchar(30) NOT NULL default '',
`message` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Data for shoutbox' AUTO_INCREMENT=13;
INSERT INTO `data` VALUES (1, 'DivL', 'Hello');
INSERT INTO `data` VALUES (2, 'DivL', 'Alo');
INSERT INTO `data` VALUES (3, 'Alo', ' juga');
INSERT INTO `data` VALUES (4, 'fd', 'fd');
INSERT INTO `data` VALUES (5, 'w', 's');
INSERT INTO `data` VALUES (6, 'w', 'f');
INSERT INTO `data` VALUES (7, 'e', 'f');
INSERT INTO `data` VALUES (8, 'e', 'fd');
INSERT INTO `data` VALUES (9, 'e', 'e');
INSERT INTO `data` VALUES (10, 'g', 'g');

