Results 1 to 6 of 6

Thread: Shoutbox

  1. #1
    Join Date
    May 2003
    Location
    Kedah
    Posts
    15
    Rep Power
    0

    Shoutbox

    Hi, i got 1 problem.This is my shoutbox script

    ----------------------------------------

    <?php
    include ("include/config.php");
    ?>

    <style type="text/css">
    body,textarea,input,h2 {font-size: 8pt; font-family: arial;}
    h1 {font-size: 10pt; font-family: arial; color: #00000; }
    </style>

    <?php

    $connect = mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error());
    mysql_select_db("$dbname", $connect) or die(mysql_error());

    function filter($text) {
    $replace=array(''=>' <img src="smiles/smile.gif">',''=>' <img src="smiles/sad.gif">',''=>' <img src="smiles/biggrin.gif">',''=>' <img src="smiles/tongue.gif">',''=>' <img src="smiles/wink.gif">','\''=>'',';'=>'','--'=>'');
    foreach($replace as $old=>$new) $text = str_replace($old,$new,$text);
    return $text ;
    }
    if(isset($_POST['submit'])) {
    //$result = mysql_query("select max(`time`), max(`banned`) from `shout` where `ip` = '".$_SERVER['REMOTE_ADDR']."'");
    //$result = mysql_fetch_array($result);
    $name = filter(wordwrap(htmlentities($_POST['name']),25,'<br />',1));
    $message = filter( substr( wordwrap( nl2br( htmlentities($_POST['message'])),32,'<br />',1),0,250));

    if (((time() - $result[0]) > 30) && ($result[1]!=1))
    mysql_query("insert into shout(`name`,`time`,`message`,`ip`) values('$name','".time()."','$message','".$_SERVER['REMOTE_ADDR']."')");
    else echo "<div style=\"background-color:#99CCFF;\"><h2>Slow down dude!</h2 ></div>";
    }

    $resultSet = mysql_query("select `name`, `time`, `message` from `shout` order by `time` desc limit 5");
    while ($record = mysql_fetch_assoc($resultSet))
    echo "<div><br>".$record['name']."<br>\n".$record['message']."<br>\n".date("h:i:s A",$record['time']). "</div>" ;
    mysql_close();

    ?>

    ----------------------------------------------------

    masalahnya sekarang, saya includekan shoutbox.php ni dlm index.php
    tapi, lepas saya submit shout, browser akan buka shoutbox.php dan bukan index.php

    mcm mana saya nak buat supaya lepas user shout, browser akan buka index.php bukan, shoutbox.php

    tq

  2. #2
    Join Date
    May 2002
    Location
    Kuching, Sarawak, MY
    Posts
    955
    Rep Power
    229
    above doesn't give us any clue. what's the form action like inside index.php? and what's inside config.php
    www.Hive.my - Hive Hosting #1 East Malaysia Web Host!

  3. #3
    Join Date
    May 2003
    Location
    Kedah
    Posts
    15
    Rep Power
    0
    this is config.php

    <?php

    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "password";
    $dbname = "project";

    ?>
    -----------------------------

    this is index.php

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body leftmargin="0" rightmargin="0">
    <table width="100%" border="0">
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td width="20%" rowspan="2">
    <?php
    include ('shoutbox.php');
    ?>
    <form action="shoutbox.php" method="post" name="shout" target="_parent">
    <input name="name" type="text" value="" size="23" maxlength="20"><br/>
    <input name="message" type="text" value="" size="23" maxlength="100">
    <input name="submit" type="submit" value="submit">
    <br/>
    </form>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>

  4. #4
    Join Date
    May 2002
    Location
    Kuching, Sarawak, MY
    Posts
    955
    Rep Power
    229
    it will open shoutbox.php because your form action is shutbox.php

    <form action="shoutbox.php" method="post" name="shout" target="_parent">

    but that's how it's suppose to work. form action must be submitted to shoutbox.php, i guess you need to use iframe in this case. any live demo for us to see?

    i have an odd feeling why even a simple shoutbox needs to be so complicated with database try www.onlyphp.com/onlyshout.php, i like this one. easy to customize and uses .txt file instead of database.
    www.Hive.my - Hive Hosting #1 East Malaysia Web Host!

  5. #5
    Join Date
    May 2003
    Location
    Kedah
    Posts
    15
    Rep Power
    0
    Thanks for the info but i have find the solution for my problem, but i dont know it is a right one or not. I just put this at the top of my shoutbox.php file

    if (eregi("shoutbox.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    }


    If my solution is wrong, correct me please. TQ

  6. #6
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    247
    A simple solution will be wrap shoutbox.php with IFRAME tag in the index.php.

    Or, if you want to use PHP include() function to embed shoutbox. Make the shoutbox redirect back to index.php after form submition(after process data).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help me!Designing shoutbox
    By Jet89 in forum Website Design
    Replies: 17
    Last Post: 03-11-2008, 06:20 PM
  2. Shoutbox n Web Counter
    By alfirus in forum Websites Review and Suggestion
    Replies: 1
    Last Post: 26-08-2006, 03:19 AM
  3. shoutbox
    By jepp in forum Website Programming
    Replies: 2
    Last Post: 29-01-2005, 09:26 PM
  4. Recommended Shoutbox?
    By lcf in forum Website Programming
    Replies: 14
    Last Post: 23-06-2004, 03:07 PM
  5. installing php shoutbox
    By sunshinerocke in forum Website Programming
    Replies: 5
    Last Post: 18-09-2003, 08:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37