I have a problem.I made a very usable comment section with a database called comment.But when I refresh the page or open it again it copies the comment that I typed for testing.How do I solve that problem.
10 2285 zmbd 5,501
Expert Mod 4TB
Have you checked the code that is being ran on the page-load?
YES!Over and over again.But I don't see anything suspicious.
Well, it's a little hard for us to say what's wrong without any code to look at.
Okay then, here are the codes. - <form action="<?php $_PHP_SELF ?>" method="POST">
-
Name: <input type="text" name="name" required="required" placeholder="eg. tox!c or benz" /><br/><br/>
-
E-mail: <input type="text" name="email" required="required" placeholder="eg. toxic5@gmail.com" /><br/><br/>
-
Comments : <br/>
-
<textarea required="required" title="Comments" rows="5" cols="50" name="comment" placeholder="Any comment welcomed...">
-
</textarea>
-
<input style="display: inline-block; background:transparent; max-width: 200px; margin: 50px 10px 30px 10px; padding: 10px; color: #000; border:1px solid #000; cursor:pointer; text-align: center;" type="submit" name="submit" value="Leave comment" onclick="Thank();"/>
-
</form>
-
-
<div style="background:lavenderblush;max-width:60em;position:relative; left:30px;box-shadow:2px 2px 2px #aaa;">
-
<div style="background:#e9967a;"><br/></div>
-
<h1>Comments</h1>
-
-
-
<?
-
include("connect.php");
-
if(isset($_POST['submit']))
-
{
-
$e=$_POST['email'];
-
$n=$_POST['name'];
-
$c=$_POST['comment'];
-
$insert=mysql_query("use codb");
-
$insert=mysql_query("insert into comment
-
(name,email,comment)
-
values ('$n','$e','$c')")or die(mysql_error());
-
}
-
$select = mysql_query("select * from comment" );
-
while ( $row = mysql_fetch_array ( $select )) {
-
echo '<h3 class="h3">'.$row [ 'name' ].'</h3>';
-
echo '<i>'.$row [ 'comment' ].'</i><br/>';
-
-
echo "<br /><hr/>";
-
}
-
-
?>
-
How come you're inserting into table comment but reading from table comment4?
It was just a mistake I made when pasting it.So I'm guessing the problem is that every time the page loads, the code fetches the data from the database and echo it.Now how do I make the php codes not to duplicate it after reloading???
Hi again, i've updated the codes to the comment section but still repeating. The newer codes are - <!-- HTML FORM -->
-
-
-
-
<h3>Leave a comment</h3>
-
-
<form action="<?php $_PHP_SELF ?>" method="POST">
-
Name: <input type="text" name="name" required="required" placeholder="eg. tox!c or benz" maxlength="25" /><br/><br/>
-
-
-
-
-
-
-
-
-
-
Comments : <br/>
-
<textarea required="required" title="Comments" rows="10" cols="50" name="comment" placeholder="Any comment welcomed...">
-
</textarea>
-
-
<input style="display: inline-block; background:transparent; max-width: 200px; margin: 50px 10px 30px 10px; padding: 10px; color: #000; border:1px solid #000; cursor:pointer; text-align: center;" type="submit" name="submit" value="Comment" />
-
</form>
-
-
-
-
<div style="background:#fff0f5; max-width:80%; margin-left:7%; box-shadow:2px 2px 2px #aaa; color:#000;">
-
<div style="background:#e9967a;"><br/></div>
-
<h1>Comments</h1>
-
-
-
-
-
-
-
<!-- INSERT COMMENT TO DATABASE -->
-
-
<?php
-
include('connect.php'); #connect to CODB
-
#Assign variables
-
$name = $_POST['name'];
-
$ip = $_SERVER['REMOTE_ADDR'];
-
$comment = $_POST['comment'];
-
$submit = $_POST['submit'];
-
-
-
#check if the user has input and store it in COMMENTS else echo out NOT INSERTED
-
if( isset($submit) ) {
-
$insert = @mysql_query("USE codb");
-
$insert = @mysql_query("INSERT INTO comment (ip,name,comment) VALUES ('$ip','$name','$comment') ");
-
echo '<span style="color:#000;background:rgba(30, 250, 30, 0.1);border:1px solid #0f0;">Inserted</span>';
-
}else {
-
echo '<span style="color:#f00;background:rgba(250, 10, 10, 0.3);border:1px solid #f00;">Please fill out all the fields correctly</span>';
-
}
-
-
?>
-
-
-
<!-- PREVIEW COMMENTS -->
-
-
-
-
<?php
-
include('connect.php'); #connect CODB
-
#Assign variables
-
$s = date("d/m/y h:i:s"); #Assign the date of input
-
$getquery = mysql_query("SELECT * FROM comment ORDER BY id DESC LIMIT 70")or die(mysql_error()); #get comments
-
-
-
-
#Check if there are comments and preview them
-
-
-
while ($rows = mysql_fetch_assoc($getquery)) {
-
$id = $rows['id'];
-
$s = $rows['submission_date'];
-
$name = $rows [ 'name' ];
-
$comm = $rows ['comment'];
-
-
-
echo "<br/>$id . <h3 style=\"font-size:25px;\">$name</h3>";
-
echo "<i>$s<br/><br/></i>";
-
echo "$comm<br/><br /><hr/>";
-
}
-
-
-
?>
-
I don't see any reason why the comment would keep inserting unless the user is constantly refreshing the page and resubmitting the data.
Yeah, i've already figured that out. It inserts, fetches and displays the last comment when refreshed. I've read a blog about making comments and at the last part he said that he edited the codes because it was repeating and that he highlighted the line, but i didn't see any highlighted line, maybe because i was using my phone, and when i tried to ask him to write the codes on the comment the page displays blank as if the blog was deleted. Any idea how i can solve this problem??? tnx
And I've also tried the
and
but no success (the
doesn't even insert the comments in the first place.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RSG |
last post by:
Hi,
Stupid question: how do I get an XSLT stylesheet to emit a comment
into the HTML output file?
Obviously this won't work; it's interpreted as a comment in the
stylesheet:
<template ...>...
|
by: Raffi |
last post by:
Here's my HTML code. What I'm trying to do is when the button is
pushed to refresh the popup window information, I want the popup to
return to the front. The way my code is now, when refreshed the...
|
by: Patrick Delifer |
last post by:
Is there a way to not let a page scroll back to the top if the user has
scrolled down and the page is refreshed?
Users are selecting Datagrid items and they are always brought back to the
top when...
|
by: Vangelis |
last post by:
Hi,
I'm currently successfully retrieving the list of computers connected on the
differents domains of our network via the
System.DirectoryServices.DirectoryEntry class.
What I'd like to have...
|
by: Rob Nicholson |
last post by:
In our application, we've added a bit of JavaScript that updates a title as
the user types into a textbox. To trigger this, we patch into the "onkeyup"
and "onpaste" events:
...
|
by: frizzle |
last post by:
Hi there
I've built this user management system, using PHP & mySQL, to manage
users that can comment on a certain site. Users have to be logged in to
comment. Below each comment is (how...
|
by: Milkstr |
last post by:
I have a database set where users predict the scores of football matches, i want to be able to display each users selection using just 2 pages, first page to select the username the second to display...
|
by: SIXFACESANKAR |
last post by:
Hi,
In my application, once the user logs in code is written in session_onstart to update / insert the user status .
Also there is code written in session_onend to update the user status again....
|
by: Siv |
last post by:
Hi,
Just busily coding away and removed a procedure from my code and all of a
sudden an error came up miles away from the location of the piece of code I
removed and it relates to the XML...
|
by: polas |
last post by:
Afternoon all. I was just wondering about this point - I have
(generally) used // for commenting a single line in C, but from
looking at code other people have written it seems many use /* */...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |