/    Sign up×
Community /Pin to ProfileBookmark

Is there a way to avoid multi-submit process if …

Is there a way to avoid multiply submit processing if a page is refreshed. For instances, if I have

[code=php]
#Delete
if(isset($_POST[‘del’])){
#do delete
}
[/code]

[code=html]
<script type=”text/JavaScript”>
function deleteIt(){
var stay = confirm(“This will DELETE this Administrator Information. Click ‘OK’ to continue and ‘Cancel’ to exit.”)
if (!stay)
window.location=”<?php echo $admin.”&_cmd=_view”; ?>”
}
//–>
</script>
[/code]

and a delete form as

[code=html]<form onsubmit=”deleteIt()” action=”<?php $admin.”&_cmd=_view”; ?>” method=”post” name=”del” id=”del”>
<input name=”delete” type=”image” id=”delete” src=”../images/btn/delete.gif” alt=”Delete <?php echo $va[‘username’] ?>” align=”bottom” />
<input name=”del” type=”hidden” id=”del” value=”<?php echo $va[‘aid’] ?>” />
</form>[/code]

If this delete button is clicked the confirmation box pops up and if I click cancel, it delete the record. If the page is refreshed, there is always a delete attempt.

Is there a way to stop this?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 12.2007 — I can only think of a session variable to store the last attempt and catch a repeated attempt.
Copy linkTweet thisAlerts:
@itbeingsauthorJan 12.2007 — Can to explain how I can do that?
Copy linkTweet thisAlerts:
@NightShift58Jan 12.2007 — Example:[code=php]<?php
session_start();
IF (!isset($_SESSION['admin_info_delete']) or ((time()-$_SESSION['admin_info_delete']) > 30)) :
$delete_ok = true;
$_SESSION['admin_info_delete'] = time();
ELSE :
$delete_ok = $false;
ENDIF;

IF ($delete_ok) :

// delete to your heart's content

ENDIF;
?>[/code]
Or, another option would to be redirect the user to a "safe" page after the deletion has taken place...
Copy linkTweet thisAlerts:
@itbeingsauthorJan 12.2007 — Thanks, I understand.
×

Success!

Help @itbeings spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...