Jump to content

Looking for a script that sends email and dowloads file onlick or other


stephenkershaw

Recommended Posts

Hi

 

I'm not a coder so don't know how to write this myself. I'm very much of the copy and paste type.

 

Basically I want a file to be downloaded and an email sent when either a link is clicked or a submit button is pressed.

 

This is so that when a particular file hosted on my site (a pdf) is downloaded I am alerted to this by an email notification.

 

Can anyone help me out with this? I assume that this can be done with PHP and MySQL but am open to suggestions.

 

Thanks in advance for your help

 

Stephen

<a href="file.php">Download</a>
<form method="post" action="file.php">
<input type="submit">
</form>

 

file.php

<?php
mail("[email protected]", "File Downloaded" , "blah blah blah(include whatever info like ip address here)");
readfile("yourfilename.pdf");
?>

 

<a href="file.php">Download</a>
<form method="post" action="file.php">
<input type="submit">
</form>

 

file.php

<?php
mail("[email protected]", "File Downloaded" , "blah blah blah(include whatever info like ip address here)");
readfile("yourfilename.pdf");
?>

 

This looks like it is on the right lines but it is not working properly just now as the file I am linking to is a pdf. So when you click the link it loads up all the pdf as code instead of bringing up the download box.

 

Thanks for your help so far though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.