Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 16-02-2005, 07:26 PM
Novice Webmaster
 
Join Date: May 2003
Location: Kedah
Posts: 15
Rep Power: 0
jepp is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 16-02-2005, 07:54 PM
Filuren's Avatar
Senior Webmaster
 
Join Date: May 2002
Location: Kuching, Sarawak, MY
Posts: 880
Rep Power: 94
Filuren is on a distinguished road
above doesn't give us any clue. what's the form action like inside index.php? and what's inside config.php
__________________
LOWEST PRICE Domain Name Promo: http://www.HiveHost.net/domains
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 16-02-2005, 10:52 PM
Novice Webmaster
 
Join Date: May 2003
Location: Kedah
Posts: 15
Rep Power: 0
jepp is on a distinguished road
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 17-02-2005, 02:20 PM
Filuren's Avatar
Senior Webmaster
 
Join Date: May 2002
Location: Kuching, Sarawak, MY
Posts: 880
Rep Power: 94
Filuren is on a distinguished road
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.
__________________
LOWEST PRICE Domain Name Promo: http://www.HiveHost.net/domains
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 17-02-2005, 05:27 PM
Novice Webmaster
 
Join Date: May 2003
Location: Kedah
Posts: 15
Rep Power: 0
jepp is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 17-02-2005, 06:06 PM
lcf's Avatar
lcf lcf is offline
Pro-Blogger
 
Join Date: Feb 2003
Location: Kluang, Johor
Posts: 2,376
Rep Power: 115
lcf will become famous soon enough
Send a message via ICQ to lcf Send a message via MSN to lcf Send a message via Yahoo to lcf
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).
__________________
LiewCF | Malaysia Bloggers Forum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shoutbox n Web Counter alfirus Websites Review and Suggestion 1 26-08-2006 03:19 AM
shoutbox jepp Website Programming 2 29-01-2005 09:26 PM
Buat ShoutBox Guna Flash Ver 6 ripcode Website Design 22 14-10-2004 05:02 PM
Recommended Shoutbox? lcf Website Programming 14 23-06-2004 03:07 PM
installing php shoutbox sunshinerocke Website Programming 5 18-09-2003 08:10 AM



All times are GMT +8. The time now is 06:26 AM. Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58