Jump to content

Can I Cancel A Form Automatically After Successfully Submitted.


Recommended Posts

Hi.. all

 

I have a problem in my web site. There I have created a page call download.php and using it users can download song. I used a form to download button to display download box. after users click on download link i need to cancel it on that page. that mean I want to disappear it on download.php page. now when i click on browser's refresh button that download box still display on page. so any body can i help me to do it..

 

http://www.mist.lk/d...ad.php?index=52

 

thanks in advance for any help....

How are you submitting the post and displaying the dowload link or etc?

Exactly.  What causes the download link to display?  Whatever that is, stop doing that after the first time.  We can't see your code.

I use a form to download button in the download page and when user click on that button the form has been submitted and display the download box on the same page. (download.php). after submitted the form it is display as long as the page open. I need to close it when a user click on browser's refresh button. that mean page should redirect to the download page.

if you were to press F5 or press the refresh button, it will resubmit the form but once you re-enter the url, i wont show it anymore.

 

what i would actually do is to set a cookie when the user press download then once the user is at the downloading page, clear the cookie.

 

the downloading will only be displayed if cookie is set.

I don't know if you need to be logged in to download, or not, but here is a simple solution (IMO).

 

- When the user clicks on the link, insert into the database either their user_id, or their ip address

- When you load the page, check to see if the value is in the database, if it is don't show it.

        - If you base it on IP address, you will probably only want to limit the last download to a certain period, due to dynamic IP addresses.

Sorry dear for your time to this...

 

Im newcomer to php and i dont have much more experience in the subject. tell me, can i use those both function in my download.php page to disappear the download box on download page? If can I do it so my problem will solve for ever.  Do you need to see my php script?

 

thanks in advance for your help.. 

Did you see my page? My problem is users click on download button a download box will display to download the songs. no problem it is ok. but problem is even after download the song that box still remaining on the page. when user refresh the page that box also display on the page then my downloaded amount also increment by 1. It is reason to insert false data in to my database. It is better if i can it disappear on the page when a user click on refresh button.. Is it possible to fix that problem...?????

change this line

 

if( isset( $_POST ['download'] ) && isset( $_POST ['download'] ) == 'Download') {

 

to this

 

if( isset( $_POST ['download'] ) && isset( $_POST ['download'] ) == 'Download' && isset($_COOKIE["downloaded"])) {
      
$expire=time()+60*60*24*30;
         setcookie("downloaded", "yes", $expire);

 

and anyway you haven't change the signature.

sorry pardon me, it should be this

 

if( isset( $_POST ['download'] ) && isset( $_POST ['download'] ) == 'Download' && !isset($_COOKIE["downloaded"])) {
      
$expire=time()+60*60*24*30;
         setcookie("downloaded", "yes", $expire);

I replaced the coding as u said then that box disappeared from the page. Now when I click the download button to download a song that box is not display again. now it is never come. without that box we cant download a song. Now my download counting also not working... actually I need to do is that download box display once and after download a song it should be disappear...

 

Thanks again for your time.. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.