Forum Moderators: open

Message Too Old, No Replies

Submit form/start download

         

geoffb

4:01 pm on Jan 11, 2010 (gmt 0)

10+ Year Member



Hi,

I need to get a 2 field form submitted to an email address as usual, and at the same time the button is clicked to send email a Zip file is downloaded and can then be opened.

Any ideas?

Cheers
geoffb

Seb7

9:10 pm on Jan 14, 2010 (gmt 0)

10+ Year Member



emailing via server? php, asp, aspx?

Maybe you need to post the form to an iframe or use ajax, then you you would be in a position to fire a javascript to start the download.

rocknbil

9:58 pm on Jan 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The solution posted in the PHP forum [webmasterworld.com] didn't work for you?

Concerned I'd missed something, I tested it.


<?php
header("content-type:text/html");
if (isset($_POST['submitted'])) {
// do all your other stuff here - send email,
// store in database, whatever - then
echo "<p>Download will start.</p>";
header("Location:test.zip");
}
else {
echo '
<form method="post" action="test-dl.php">
<input type="hidden" name="submitted" value="1">
<input type="submit" value="Submit and Download">
</form>
';
}
?>

geoffb

11:04 pm on Jan 14, 2010 (gmt 0)

10+ Year Member



Hi rocknbil
Nice to hear from u again. I did an easy solution as time was critical
And just did the form as normal the loaded a download button off the thank
You page. Have u tried the code as I will keep it for future ref!

Cheers as always.
Geoffb