Simple Shoutbox In Php

free web hosting
Open Discussion > CONTRIBUTE > Tutorials

Simple Shoutbox In Php

.hack//GU
This is a simple shoutbox I created in the past for my class.

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


“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);
?>


“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);
?>


“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);
?>


“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);
?>


“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);
?>


“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');

 

 

 


Reply

Forbez
Nice, quite simple. I'm sure you can make it smaller then that. But it's still very good. What grade did you get for it in class?

Reply

suberatu
It seems good, but do you think you could possibly give a brief expanation of what each segment of code does exactly? You know, for those of us who aren't so fluent in php but might want to make tiny modifications to such a shoutbox.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. php simple shoutbox tutorials - 602.55 hr back. (1)
  2. cache:feihi3xxlncj:www.trap17.com/index.php/make-flat-based-shoutbox-auto-refresh_t57148.html php shoutbox auto refresh code - 700.91 hr back. (1)
  3. simple shout script to insert in webpage - 1121.86 hr back. (1)
Similar Topics

Keywords : simple, shoutbox, php

  1. Make A Flat Based Shoutbox, With Auto Refresh.
    (6)
  2. Simple Shoutbox
    PHP, MySQL driven.. (34)
    Ok, so I'm going to show you how to create a very basic shoutbox which is driven with PHP and a
    MySQL database. So, lets start - open a database management program like PHPMyAdmin and run these
    queries. SQL CREATE TABLE `shoutbox` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT
    , `name` VARCHAR( 255 ) NOT NULL , `mail` VARCHAR( 255 ) NOT NULL , `time`
    VARCHAR( 255 ) NOT NULL , `message` TEXT NOT NULL , `ip` VARCHAR( 255 ) NOT NULL ,
    PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; CREATE TABLE `shoutbox_a....
  3. How To Make A Simple File Based Shoutbox Using Php And Html
    (8)
    A simple tut to make a simple shoutbox. Let me jump right in. First of all you need the standard
    equipment for PHP, an IDE like XAMPP and an editor like PHP EDITOR 2OO7. Were going to make a
    simple guestbook using three files, webpage.php, shout.php and shout.txt. Webpage.php can be
    changed to whatver you want, it will be the page on which the guestbok is shown, you could even use
    this code and add it to another php page n your site. Shout.php is the proccessing page and
    shout.txt is where the shouts are stored. Firstly we need to make the visual design of the box.....
  4. Features That You Can Use In The Shoutbox
    (5)
    Some people dont know all of the features that the shoutbox has so im going to write about it
    explaining it. Viewing Statistics In D21-Shoutbox 1.2 I have seen a few shouts in
    the shoutbox asking how to view the Statistics for the Shoutbox, and it is quite simple actually.
    First you need to click on "View The Shoutbox" which is located on the top bar of the Shoutbox,
    it is located right next to "Latest Shouts In The Shoutbox" Once you are there, look in the
    Trap17 Shoutbox section for My Control Panel Then it should be self ex....
  5. Tutorial: Installing D-shoutbox For Ipb V1.2
    Making your installation even easier (12)
    Over the course of the summer I have tried hard to install a shoutbox into a new forum I was
    developing. I went to the Invisionalize forums and found several mods for shoutboxes, but none of
    them seemed to work. I first tried to install the D-Shoutbox, but upon this first try, I was
    unsuccessful. Eventually, after much frustration, and trying other mods, which didn't seem to
    stack up to Dean's features, I was determined to make it work. For some, editing your files (to
    the newbie that is) can be difficult, with everything looking like a foreign language (basi....
  6. Shoutbox, Made Easy!
    kShoutBox 0.3 ... now more powerful! (2)
    kShoutBox 0.3 QUOTE(readme.txt) Readme file to kShoutBox 0.3 To use the internet explorer
    fix: Extract the ie7 folder to the root directory of your web server. Example, if you are using a
    unix/linux server, it's on "public_html/" or "home/public_html" Then, extract the kShoutBox.php
    file in to the root directory of your web server also. After that, open kShoutBox.php using your
    Editor, then modify the MySQL Database username, and password. (if you are using cPanel, make sure
    that you create a database manually, then enter the database name on hte kShout....
  7. Shoutbox, Made Easy! Again!
    with another version! (2)
    kShoutBox 0.2 has been released! For more information, go to http://www.karlo.ph.tc
    /* ****************************** kShoutBox 0.2 ****************************** */
    /* **************************************** This ShoutBox script was created by Juan Karlo Aquino
    de Guzman DO NOT MODIFY THIS CODE AND DISTRIBUTING IT WITHOUT ANY PERMISSION. E-MAIL THE AUTHOR
    FIRST. Email: 01karlo@gmail.com DO NOT REMOVE THE "POWERED BY". FOR SUGGESTIONS, COMMENTS, ETC,
    SEND AN EMAIL TO 01karlo@gmail.com HOPE THAT YOU ENJOY THIS SCRIPT! MY FRIEN....
  8. Shoutbox, Made Easy
    PHP+MySQL ShoutBox! Very simple... (17)
    Just create a PHP file named "kShoutBox.php" CODE <?php header("Content-type:
    text/html; charset=utf-8"); //Send to browser that the charset is utf-8 ?> <?php
    /* ******************************   kShoutBox 0.1 ****************************** */
    /* **************************************** This ShoutBox script was created by Juan Karlo Aquino
    de Guzman DO NOT MODIFY THIS CODE AND DISTRIBUTING IT WITHOUT ANY PERMISSION. E-MAIL THE AUTHOR
    FIRST. Email: 01karlo@gmail.com DO NOT REMOVE THE "POWERED BY". FOR SUGG....

    1. Looking for simple, shoutbox, php

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for simple, shoutbox, php

*MORE FROM TRAP17.COM*
advertisement



Simple Shoutbox In Php



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE