Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 10th, 2008, 02:58 PM
Authorized User
 
Join Date: Aug 2006
Location: , , USA.
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?

Reply With Quote
  #2 (permalink)  
Old September 17th, 2008, 03:13 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old September 25th, 2008, 01:12 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 481
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


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



All times are GMT -4. The time now is 05:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.