thara Posted November 4, 2011 Share Posted November 4, 2011 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.... Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 if you are using session to check if the form is submitted, you might want to session_destroy it. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284870 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 If I don't use session.. is there any way to do it? Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284876 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 How are you submitting the post and displaying the dowload link or etc? Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284891 Share on other sites More sharing options...
ManiacDan Posted November 4, 2011 Share Posted November 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284898 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284914 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284947 Share on other sites More sharing options...
The Little Guy Posted November 4, 2011 Share Posted November 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284952 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 @The Little Guy this is the link for the site. i don't think you would require login cause i am able to access the site without any logins. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284960 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 Thanks Dear... Can I use session for my download page without login system. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284974 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 YES. remember to start the session first. <?php session_start(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284979 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 thanks.. then how can i destroy the session Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284988 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 <?php session_destroy(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284992 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1284998 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 yes, please post your codes here. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285011 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 This is my download.php page [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285014 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 ouh great, you just copied my signature eh? i deserve some recognition... TharangaGinigathena *Design*Create*Code anyway, what do you want the page to do? Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285017 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 sorry sorry my dear. I will change it. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285019 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 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...????? Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285022 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 using cookie should help? Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285027 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285028 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 Ok. dear thank you very much.. I have changed the signature Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285031 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285032 Share on other sites More sharing options...
thara Posted November 4, 2011 Author Share Posted November 4, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285039 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 4, 2011 Share Posted November 4, 2011 add this <?php if (!isset( $_POST[ 'submitted5' ])) { $expire=time()-60*60*24*30; setcookie("downloaded", "",$expire); } ?> before this <?php if ( isset( $_POST[ 'submitted5' ])) { Quote Link to comment https://forums.phpfreaks.com/topic/250429-can-i-cancel-a-form-automatically-after-successfully-submitted/#findComment-1285043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.