Tutorials : Create Simple ShoutBox

Discussion in 'PHP' started by mizuki, Jan 31, 2007.

  1. #1
    Hi,this is simple tutorials to create shoutbox.
    Full tutorial you can view here :
    http://www.t4vn.net/tutorials/showtutorials/Create-Simple-ShoutBox.html

    Step 1 : Create database with information :
    CREATE TABLE `tagboard` ( 
    `id` int(7) NOT NULL auto_increment, 
    `name` varchar(250) NOT NULL default '', 
    `comments` text NOT NULL, 
    `date` timestamp(14) NOT NULL, 
    PRIMARY KEY (`id`), 
    ) TYPE=MyISAM AUTO_INCREMENT=419 ;
    PHP:
    Step 2 : Create file config.php with content
    <? 
    $dbuser=""; //Database Username 
    $dbname=""; //Database Name 
    $dbpass=""; // Database Password 
    ?> 
    PHP:
    Step 3: Create File tag.php with content :
    <iframe src="view.php" name="tag" width="179" height="130" frameborder=0 marginwidth="0" marginheight="0"></iframe><form method="POST" ACTION="todo.php"> 
    <input type="text" NAME="name" Value=">"> 
    <textarea NAME="post" cols="27" rows="3"></textarea> 
    <br> 
    <input TYPE="submit" value="Submit">
    PHP:
    Step 4: Create file todo.php with content :
    <?php 
    if ($name == '' || $post == ''") 
    { 
    die ("Please fill all fields. Click <a HREF=tag.php>here</a> to return."); 
    } 
    include('config.php'); 
    
    $post = preg_replace("/</","&lt;",$post); 
    $post = preg_replace("/>/","&gt;",$post); 
    $post = nl2br($post); 
    $comments = "$post"; 
    } 
    
    $c=mysql_connect("localhost","$dbuser","$dbpass"); 
    mysql_select_db($dbname); 
    $todo="INSERT INTO tagboard (id,name,comments,date) VALUES('','$name','$comments',now())"; 
    $solution = mysql_query($todo) or die (mysql_error()); 
    if ($solution) 
    { 
    ?> 
    <meta http-equiv="refresh" content="0;url=tag.php" > 
    <? 
    } ?>
    PHP:
    Step 5 : Finally,create file view.php with content :
    <?php 
    include('config.php'); 
    
    $c=mysql_connect("localhost","$dbuser","$dbpass"); 
    
    mysql_select_db($dbname); 
    
    $todo='SELECT * FROM `tagboard` order by id desc LIMIT 50'; 
    $solution=mysql_query($todo); 
    while ($place = mysql_fetch_array($solution)) 
    { 
    $id=$place["id"]; 
    $comments=$place["comments"]; 
    
    ?> 
    »<b><? echo "$place[name]"; ?></b><? echo ": $comments<br>" ; ?> 
    <? 
    }?> 
    PHP:
    You're done.
    Good luck:
     
    mizuki, Jan 31, 2007 IP
  2. mantero

    mantero Well-Known Member

    Messages:
    612
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #2
    tq very much. do u know how to use ajax to create shoutbox?
     
    mantero, Feb 1, 2007 IP
  3. mizuki

    mizuki Well-Known Member

    Messages:
    210
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #3
    ==>maybe I will write it in future.
     
    mizuki, Feb 1, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's not a tutorial, that's a ready-made shoutbox. A tutorial implies you actually explain what's going on (although from the look of it, I'm not sure you even know yourself?)..
     
    rodney88, Feb 1, 2007 IP