?
Solved

refresh runs update query

Posted on 2011-09-28
9
Medium Priority
?
307 Views
Last Modified: 2012-05-12
how do i clear the refresh cache or the last process from being ran again?

say for instance:

i type a comment on a picture i click refresh and it wants to send comment again. how do i get it to where it doesnt want to send again it will just refresh the page and not the update query.

do i clear the cache and then require it to refresh it self or what?

thanks in advance for your help!
0
Comment
Question by:only1wizard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36720030
The code?
A link?

we're not psychic :)
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720087
That is normal operation for Refresh.  If you want it to do something else, you need it to go to a page that was Not loaded with a POST or form submission.  Click on another link.  ??
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36720172
The best answer I have found is to write your code in such a way that the refresh does not adversely affect the data model.  Refresh happens.  
0
 

Author Comment

by:only1wizard
ID: 36720566
hello -

thanks for the quick response this is what i have:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {

// do database insert

}

Open in new window


<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
      <table align="left">
        <tr valign="baseline">
          <td nowrap="nowrap" align="left">catagory:</td>
          <td><select name="catagory">
            <?php
do {  
?>
            <option value="<?php echo $row_cat['Id']?>"><?php echo $row_cat['catagory']?></option>
            <?php
} while ($row_cat = mysql_fetch_assoc($catagory));
  $rows = mysql_num_rows($catagory);
  if($rows > 0) {
      mysql_data_seek($catagory, 0);
	  $row_cat = mysql_fetch_assoc($catagory);
  }
?>
          </select>
</td>
        </tr>
        <tr valign="baseline">
        	<td nowrap="nowrap" align="left">feelings </td>
            <td><textarea name="feelings" cols="32" rows="3" ></textarea></td>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Submit" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form2" />
    </form>

Open in new window


can i do an unset($_Post)? after it has completed its database inserts with out errors?

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720734
You can do that but it has no effect on the Refresh because the Refresh page load is done in the browser.  Clicking on submit POSTs data from the form to an 'action' page.  If you Refresh the 'action' page, the browser will send the data gain because that is how it got to that page.  That is how it is supposed to work.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 36727384
For better or worse, computer programming requires precision.  The PHP statement unset($_Post) will have no effect at all because PHP variable names are case-sensitive.  You would want unset($_POST).  And that would not work, either because the refresh would send a new POST array.

Here is how you can prevent repeated requests.  Please read it over carefully and post back with any questions.

Best of luck with it, ~Ray
<?php // RAY_multi_submit.php
error_reporting(E_ALL);


// PREVENT MULTIPLE SUBMISSIONS DUE TO REPEATED REFRESH, CLICKS ON SUBMIT BUTTON OR FIRING THE BACK BUTTON
// EXAMPLE:
//    if ( multi_submit() )
//    {
//       handle error
//    }
//    else
//    {
//       normal processing
//    }


// ALWAYS START THE PHP SESSION ON EVERY PAGE
session_start();



// A FUNCTION TO RETURN TRUE OR FALSE ABOUT MULTI-SUBMIT CONDITIONS
function multi_submit($type="POST")
{
    // MAKE THE FUNCTION WORK FOR EITHER GET OR POST SUBMITS
    $input_array = (strtoupper($type) == "GET") ? $_GET : $_POST;

    // GATHER THE CONTENTS OF ALL THE SUBMITTED FIELDS AND MAKE A MESSAGE DIGEST
    $string = NULL;
    foreach ($input_array as $val)
    {
        // CONCATENATE ALL SUBMITTED VALUES
        $string .= $val;
    }
    $string = md5($string);

    // IF THE SESSION VARIABLE IS NOT SET THIS IS NOT A MULTI-SUBMIT
    if (!isset($_SESSION["_multi_submit"]))
    {
        // SAVE THE SUBMITTED DATA MESSAGE DIGEST
        $_SESSION['_multi_submit'] = $string;
        return FALSE;
    }

    // IF THE SESSION DATA MATCHES THE MESSAGE DIGEST THIS IS A MULTI-SUBMIT
    if ($_SESSION['_multi_submit'] === $string)
    {
        return TRUE;
    }
    else
    {
        // SAVE THE MESSAGE DIGEST TO DETECT FUTURE MULTI-SUBMIT
        $_SESSION['_multi_submit'] = $string;
        return FALSE;
    }
}



// SHOW HOW THIS IS DONE
if (!empty($_POST))
{
    if (multi_submit())
    {
        die("ALREADY GOT THAT");
    }
}



// CREATE THE FORM FOR THE DEMONSTRATION
$form = <<<FORM
<form method="post">
ENTER SOMETHING, THEN REENTER IT
<input name="foo" />
<input type="submit">
</form>
FORM;

echo $form;

Open in new window

0
 

Author Comment

by:only1wizard
ID: 36732805
thanks for the example  i will give this a try and post results!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36737474
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question