954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Prevent fetching data on page refresh

i want my code to Prevent fetching data on page refresh

<?php $name=$_POST['name']; ?>
<html>
<body>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name">
<input type="submit" value="GO" name="submit">
</form>
</body>
</html>

<?php
	include ('db.php');
	if(isset($_POST['submit'])) 
	{
	mysql_query ("INSERT INTO example (name) VALUES('$name')") or die(mysql_error());
	}

	if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
	$startrow = 0;
	} 
	else {
	$startrow = (int)$_GET['startrow'];
	}
	
$query = "SELECT * FROM example ORDER BY id DESC LIMIT $startrow, 20"; 
$result = mysql_query($query) or die(mysql_error());

	while($row = mysql_fetch_array($result)){
	echo "<li>";
	echo $row['name'] ." "." <a href= 'like.php?quote=" . urlencode( $row['name'] ) . "'>Click Here</a>";
	echo "</li>";
}
	
	echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';
?>


when i am refreshing the page the same data is fetching again which i had posted before refresh.

Xufyan
Posting Whiz
309 posts since Mar 2010
Reputation Points: 6
Solved Threads: 7
 

Have a look at some of the previous posts on the same topic:

http://www.daniweb.com/forums/search13400429.html

chrishea
Nearly a Posting Virtuoso
1,429 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: