Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2008, 02:58 PM
Authorized User
 
Join Date: Aug 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default hit F5 refresh triggers again the query

When i hit the F5 to refresh the page, sql statement in that page runs again. It means last insert, update or delete process is triggered again. How can i solve this problem?

 
Old September 17th, 2008, 03:13 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

You need to use cookies both in javascript and php
<?
  if ($_COOKIE['pagename_displayed']==0) //if page is not displayed then only execute
   {
       //insert,update, statement
      //this portion will only exeucte once, it will not execute on F5, when user submit form then we manual set cookie to 0 and then only this portion will execute. Also learn cookies in javascript following javascript code is just a place holder.
  }
?>
<html>

<script language=javascript>
function submit()
{
  //reset cookie meansm, page is not displayed
    setcookie('pagename_displayed',0);
/*setcookie is not inbuild javascript function you need to create function after learing handling cookies in javascript*/


    docuent.frm.submit();
}
</script>

<body>
<form>
<input>....................

</form>
</body>

<script language=javascript>
  setcookie('pagename_displayed',1);//we are setting page is displayed
</script>
</html>

urt

Help yourself by helping someone.
 
Old September 25th, 2008, 01:12 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
then use session
start a session before insert page,
check the session before insert command write, then make the session false.
like this.

1.php
$_SESSION['u']=true;

2.php
if($_SESSION['u']==true){
//insert statment
$_SESSION['u']==false;
}



surendran
(Anything is Possible)
http://www.suren.info
http://ssuren.spaces.msn.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
F5 (Refresh) adds a new record after postback krainov BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 20th, 2007 10:10 AM
XL2000: Query Table’s Refresh method with ADO Rod the mod Excel VBA 3 April 5th, 2005 01:28 PM
Refresh Query Results Ben Access VBA 2 February 10th, 2004 10:58 AM
Refresh causing Query Engine Error Deecay Crystal Reports 0 July 10th, 2003 09:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.