Jump to content


Photo

SHOUT BOX


  • Please log in to reply
5 replies to this topic

#1 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 10 August 2006 - 02:40 PM

hey hey all...ok i wanna have a shout box where there is a scrolling area like a marquee on the top of my page saying what is happening.... any way i can do this all  please please help

#2 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 10 August 2006 - 05:07 PM

Make a form with a textarea.. post the data and insert it into your database.

Then just print the variable of the retrieve from your database onto your page with a marquee.

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 10 August 2006 - 05:11 PM

That won't work :) Because when the user refreses the page it'll be gone. You need to write it into a file/database. Then, every time read the file/table.

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 SieRobin

SieRobin
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts
  • LocationNew Jersey

Posted 10 August 2006 - 05:14 PM

Why wouldn't that work? I do it all the time Orio. He wants to make a ShoutBox, meaning he basically wants to update the text in the marquee everytime he submits a new piece of information in the textarea. After he hits the button, it posts the data into his database making the variable, $shoutbox visible to everyone, instead of manually going into the database everytime to update the shout out.

#5 mewhocorrupts

mewhocorrupts
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationParker, CO

Posted 10 August 2006 - 08:53 PM

I'm confused, as well.  It sounds like both of you said the same thing.
-mewhocorrupts

#6 runnerjp

runnerjp
  • Members
  • PipPipPip
  • Advanced Member
  • 2,214 posts

Posted 11 August 2006 - 07:31 PM

yup ok im really really confuzzeld
i have made the shout box

<style type="text/css">


<!--


body,td,th {


        font-size: 14px;


        font-weight: bold;


        color: #FFFFFF;


}


body {


        background-color: #333333;


}


-->


</style><b>


<?php


// You just need to configure these 4 variables to match your server.


include("config/config.php");


// If a user has submitted a post, we want to :


// 1. Validate it


// 2. Strip unwanted html


// 3. Make sure messages and names aren't too long


// 4. Add it to our database.


if($_POST['submit']) {


// 1. Validate it, by checking all the form inputs were filled in


    if(!$_POST['author']) {


        echo 'Error ! : No name entered';


        die;


    }


    if(!$_POST['eml']) {


        echo 'Error ! : No email entered';


        die;


    }


    if(!$_POST['message']) {


        echo 'Error ! : No message entered';


        die;


    }


// 2. Strip unwanted HTML


// Look up the strip_tags() function at


// http://www.php.net/manual/en/function.strip-tags.php for more info


    $message = strip_tags($_POST['message'], '');


    $eml = strip_tags($_POST['eml'], '');


    $author = strip_tags($_POST['author'], '');


// 3. Make sure messages and names aren't too long


// We will use the strlen() function to count the length.


    $message_length = strlen($message);


    $author_length = strlen($author);


    if($message_length > 150) {


        echo "Error ! : Your message was too long, messages must be less than 150 chars";


        die;


    }


    if($author_length > 150) {


        echo "Error ! : Your name was too long, names must be less than 150 chars";


        die;


    }


// 4. Add it to our database.


// If the script hasn't died yet due to an error in the inputted data


// we need to add the data to the database


// Lets connect to our database.


    mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());


// Select the database.


    mysql_select_db($dbname) or die(mysql_error());


// Lets define the date format we want to enter to our database


// go here for more details


// http://www.php.net/manual/en/function.date.php


    $date = date("h:i A dS M");


// This will produce 11:02 25th Aug


// Set the query as $query


    $query = "INSERT INTO shoutbox (message, author, eml, date, ip)


VALUES ('$message','$author','$eml','$date','$_SERVER[REMOTE_ADDR]')";


    mysql_query($query);


    mysql_close();


    // Show thanks message and take them back to the main shoutbox


    echo "Thanks for your post<BR>";


    echo "<A HREF='shoutbox.php'>View the shoutbox</A>";


// If they haven't submitted a post, we want to :


// 1. Show the latest shouts


// 2. Show the shout post form


} else {


// 1. Show the latest shouts


// Lets connect to our database.


    mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());


// Select the database.


    mysql_select_db($dbname) or die(mysql_error());


// Set the query as $query, and get the last 10 posts.


    $query = "SELECT message, author, eml, date, ip


FROM shoutbox order by id DESC LIMIT 10";


    $result = mysql_query($query);


    echo "<TABLE>";


    while($r=mysql_fetch_array($result))


    {


// To modify the appearance, edit this :


        echo "<TR>


            <TD><font size='1'>


Posted $r[date] by <A HREF='mailto:$r[eml]'>


$r[author]</A></font></TD>


        </TR>


        <TR>


            <TD><font size='1'>$r[message]</font></TD>


        </TR>


        <TR>


            <TD><HR></TD>


        </TR>";





    }


    echo "</TABLE>";


// 2. Show the shout post form


?><style type="text/css">


<!--


body,td,th {


        font-family: BankGothic Lt BT;


        font-size: 12px;


}


a:link {


        color: #000000;


}


a:visited {


        color: #000000;


}


a:hover {


        color: #000000;


}


a:active {


        color: #000000;


}


-->


</style>





    <FORM METHOD=POST ACTION="shoutbox.php">


    <TABLE>


    <TR>


        <TD>Name :</TD>


        <TD><INPUT TYPE="text" NAME="author"></TD>


    </TR>


    <TR>


        <TD>Email :</TD>


        <TD><INPUT TYPE="text" NAME="eml"></TD>


    </TR>


    <TR>


        <TD>Message :</TD>


        <TD><INPUT TYPE="text" NAME="message"></TD>


    </TR>


    <TR>


        <TD>&nbsp;</TD>


        <TD><INPUT TYPE="submit" name="submit" value="post"></TD>


    </TR>


    </TABLE>


    </FORM>


<?php


}


?>


</b>

ok i want to add a marquee on my homepage (index page) just showing some of the new posts...can any one give me code to do this cos wats said above is very confuzzlin haha




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users