473,324 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Shoutbox refresh problem

Hi all,
I've built this shout box to go on my web page but have hit a
snag.
Everytime i refresh the page the last entry is reloaded onto the top
of the list. this is causing the list to become filled with the same
commentsw every time i refresh the page. I've tried resesting the
variables after they have been used but to no avial. please plese
help!! :p

The full listing is below:

<div class="Shout"> <a name="shout"></a>
<div class="ShoutTop"> <img src="tl.gif" alt="" width="15"
height="15" class="corner" style="display: none" />
<p class="subtitle" align="center">Leave your shout outs
below!</p>
<br>
<p class="text3" align="center">Fill in your name, write your
shout and hit
submit!</p>
<br>
</div>
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post"><LABEL
for="name"><p>
Name:</LABEL></span><br>
<INPUT TYPE='TEXT' NAME='nameSub' SIZE=15 maxlength='100'
id="name" value="Name">
<br>
<LABEL for="comment"><p>Shout:</LABEL>
<br>
<INPUT TYPE='TEXT' NAME='commentSub' SIZE=15 maxlength='100'
id="comment" value="Comments">
<br>
<br>
<div class="Submit">
<input type='hidden' name='status' value='1'>
<input type="submit" name="submit" value="submit">
</div>
</form>
<?php
include("connect.php");
$link = mysql_connect(HOST,USER,PASSWORD) or die("ERROR: Could not
connect to DB");
mysql_select_db(DATABASE,$link) or die("ERROR: Could not connect to
DB");

// status

$status = $_POST['status'];
$name = $_POST['nameSub'];
$comment = $_POST['commentSub'];

//update and repopulate shoutbox
if($status == 1) {

$status = 0; //reinitialise

if($name == "" && $comment == "") {

$result = mysql_query("SELECT * FROM shoutbox order by id DESC limit
8");

while($row=mysql_fetch_array($result))
{

echo "<p class=text3>$row[name]:</p>";
echo "<p class=text4>$row[comment] <br>";

}

$name = "";
$comment = "";

}

elseif($name == "" && $comment != "") {

$status = 0; //reinitialise

$query = "INSERT INTO shoutbox (name,comment) VALUES
('Anon','".$comment."')";

$result = mysql_query($query,$link) or die("ERROR: Could not enter
data. ".mysql_error());

$result = mysql_query("SELECT * FROM shoutbox order by id DESC limit
8");

while($row=mysql_fetch_array($result))
{

echo "<p class=text3>$row[name]:</p>";
echo "<p class=text4>$row[comment] <br>";

}

$name = "";
$comment = "";

}

else {

//print "<br><br>shud be entering comments into db here<br>";
//Print "passed name: ".$name."<br>";
//Print "passed message: ".$comment."<br>";

$status = 0; //reinitialise

$query = "INSERT INTO shoutbox (name,comment) VALUES
('".$name."','".$comment."')";

$result = mysql_query($query,$link) or die("ERROR: Could not enter
data. ".mysql_error());

$result = mysql_query("SELECT * FROM shoutbox order by id DESC limit
8");

while($row=mysql_fetch_array($result))
{
echo "<p class=text3>$row[name]:</p>";
echo "<p class=text4>$row[comment] <br>";

}

$name = "";
$comment = "";

}

}

else {

$result = mysql_query("SELECT * FROM shoutbox order by id DESC limit
10");

while($row=mysql_fetch_array($result))
{

echo "<p class=text3>$row[name]:</p>";
echo "<p class=text4>$row[comment] <br>";
}

}
?>
<div class="ShoutBottom"> <img src="bl.gif" alt=""
width="15" height="15" class="corner"
style="display: none" /> </div>
</div>
Jul 17 '05 #1
0 2019

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits...
3
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a...
5
by: Steve | last post by:
Hi, I have a private website for 20 people that is similar to a web email client like hotmail. There are two frames, one on the left with links for "New", "History", "Todays" and a frame on the...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
1
by: ppatel | last post by:
Problem I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine). When click...
12
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
by: ire.kevin | last post by:
Well I've made alot of progress (ok i lie someone made alot of progress for me) but I'm at a hault because i get the "can't write to db" error down in the code. What's wrong? I can't find it.......
10
by: rinawmt | last post by:
hello fren... i'm using joomla software in my website. There i put one shouth box... and for that shoutbox i'm using Ajax shoutbox, there when ever people shouth using through Guest or the member...
4
by: Svinja | last post by:
Hello, I made a shoutbox in php, the problem is that i am sending shoutbox data(name and text) with submitting forms, that way i get POSTDATA. The question is, can i send my shoutbox data to php...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.