+ Reply to Thread
Results 1 to 7 of 7

Thread: PHP Shoutbox

  1. #1
    Mani5 is offline x10 Lieutenant Mani5 is an unknown quantity at this point
    Join Date
    Sep 2005
    Posts
    473

    PHP Shoutbox

    Source: http://www.media-ops.com

    My first ever tutorial! (php wise...). I first made this for www.re-mi.be, which is currently down, and then updated it and now i use it on my personal site www.r.dsx3.com :P. Its a basic script, but if you would like a shout box then it is perfect :P.

    There will be 5 parts to this tutorial:
    >Making the SQL Table
    >Creating the Form
    >Creating the Action
    >Creating the Output
    >Creating the index

    lets get started :P.

    Open up Phpmyadmin, or whatever you use for sql. Run this query
    Code:
    CREATE TABLE `shout` (
    `id` INT NOT NULL AUTO_INCREMENT ,
    `name` TEXT NOT NULL ,
    `message` TEXT( 100 ) NOT NULL ,
    PRIMARY KEY ( `id` )
    );


    You can change the 100 (in the paranthesis) to however many characters you would like to limit the peoples messages to.

    What the query does, for people who dont get it: It creates a table called shout, and makes three rows. ID, name, and message. The name and message are inputted by the user, and the id automaticaly increases each time a person "shouts".

    now create a directory called shout. You dont want things to get all ugly and disorganized :P.

    Now we are going to create the form. Name this add.php
    Code:
    <form name="addform" method="post" action="shoutbox/action.php">
    <table width="150" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><b>Name:</b></td>
    <td><input type="text" id="name" name="name"></td>
    </tr>
    <tr>
    <td><b>Msg:</b></td>
    <td><input type="text" id="message" name="message"></td>
    </tr>
    </table>
    <table width="150" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center"><input type="submit" name="shout" title="shout" value="shout"></td>
    </tr>
    </table>
    </form>


    I put it in the table so i could control the alignment :P. You could/should add some css, to make the inputs look pretty :P, because the default ones arent so.

    Now we are going to make the action file. Name this action.php <-- :P

    Code:
    <?php

    //fill it out according to the sql table you set up
    $username="Username";
    $password="Password";
    $database="Database";
    $table="shout";

    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");

    $query="INSERT INTO $table (id, name, message) values ('$id','$name','$message')";
    $result=mysql_query($query);
    echo "Succsesfully Shouted. <a href=\"http://www.yoursite.com\">Return</a>";
    ?>


    Make sure, when you change the href, to keep the last \ there :P. Change the username pswrd and databae names also.

  2. #2
    Fire Wolf is offline x10 Sophmore Fire Wolf is an unknown quantity at this point
    Join Date
    May 2005
    Posts
    240

    Re: PHP Shoutbox

    Any preview?

  3. #3
    rahul2006 is offline x10 Sophmore rahul2006 is an unknown quantity at this point
    Join Date
    Oct 2005
    Location
    IN THE HELL , WANT TO JOIN THEN PM ME
    Posts
    214

    Re: PHP Shoutbox

    pls explan in some other way

  4. #4
    motogawa's Avatar
    motogawa is offline x10 Sophmore motogawa is an unknown quantity at this point
    Join Date
    Oct 2005
    Location
    Indianapolis, IN
    Posts
    153

    Re: PHP Shoutbox

    He wants to know if you have like a display of the shoutbox in work.
    PHP, AJAX, SQL, Javascript Programmer!
    Need help ask me!

  5. #5
    Mani5 is offline x10 Lieutenant Mani5 is an unknown quantity at this point
    Join Date
    Sep 2005
    Posts
    473

    Re: PHP Shoutbox

    no I dont sorry.......{embarresed}

    but I hav an easier solution..go to MYSHOUTBOX.com and register and configure smileys and everythin then when u r all done, click da Code generator thing..and Voila! u will get a code u can put on ur PHP/HTML site and its so easy set up...

    ENJOY

    P.S. they giv previews...

  6. #6
    rahul2006 is offline x10 Sophmore rahul2006 is an unknown quantity at this point
    Join Date
    Oct 2005
    Location
    IN THE HELL , WANT TO JOIN THEN PM ME
    Posts
    214

    Re: PHP Shoutbox

    thank u for the shout box

  7. #7
    Mani5 is offline x10 Lieutenant Mani5 is an unknown quantity at this point
    Join Date
    Sep 2005
    Posts
    473

    Re: PHP Shoutbox

    Welcome! I m glad it helped u......



    ---------------------------------------------------------------------
    Advertising

    Spectre Productionz

    Symbionic

    Want your site here? PM me and 5 points a week.

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers