File download and Thanks page call in one button press

brendapeace

New Member
I have a downloads page on a site with links to lots of ZIP files. I want to allow the user to click the download button to download the ZIP file - additionally when they click the button I want the browser to re-direct the user to a thanks page.Is this possible? The site is PHP based if that helps!I've read that you can't do this on one press, so the needs to call the downloads-thanks page, and then serve the download file function from the thanks page... How is that possible if I have loads of download buttons/files though? Would need to send a variable from the downloads page to the downloads-thanks page to allow the thanks page to process the correct file to download???Any ideas?Thanks*** update ***OK, I have had a go at implementing the PHP variable and GET function - but am having no joy, the code is as below and a link to the live example here - http://www.jonwallacedesign.biz/clients/cartotype/downloads/ - The call to load the thanks page gets ignored and I just get prompted to save the file download???Downloads page:\[code\] <a href="http://www.jonwallacedesign.biz/clients/cartotype/downloads/thanks.php?file=zip1">zip1</a> <a href="http://www.jonwallacedesign.biz/clients/cartotype/downloads/thanks.php?file=zip2">zip2</a> <a href="http://www.jonwallacedesign.biz/clients/cartotype/downloads/thanks.php?file=zip3">zip3</a>\[/code\]thanks.php page:\[code\] <?php $file = $_GET['file']; if($file == "zip1") { header("Location: http://www.jonwallacedesign.biz/clients/cartotype/downloads/zip1.zip"); } else if($file == "zip2") { header("Location: http://www.jonwallacedesign.biz/clients/cartotype/downloads/zip2.zip"); } else if($file == "zip3") { header("Location: http://www.jonwallacedesign.biz/clients/cartotype/downloads/zip3.zip"); } echo "Thankyou for downloading"; ?>\[/code\]*** update 2 ****Have abandoned PHP as the actual PHP download page never gets to render on screen - it serves up the correct download but the thanks page never renders... Went with a JS solution as below:\[code\] <script> function thanks() { setTimeout(function () { document.location.pathname = "thanks.html"; }, 1000); } </script> <a href="http://stackoverflow.com/questions/9398973/zip1.zip" onclick="thanks()">zip1</a>\[/code\]
 
Top