Jump to content

SHOUT BOX


runnerjp

Recommended Posts

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.
Link to comment
Share on other sites

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

[code]<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>[/code]

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.