How to acheive with Dreamweaver 4: One click on text link, with two simultaneous actions taken

With Dreamweaver 4, is it possible to click a text link on a page and have two things happen at once, in my case, initiate a download, AND send me an email automatically, without intervention from the user, with a small message saying "Download initiated"?
pigeonbrAsked:
Who is Participating?
 
Jason C. LevineNo oneCommented:
I can, I just want to do something you'll actually find useful.  Here's the PHP:

<?php

// first, we set up the notification email

$to = "myemail@hotmail.com";
$subject = "Download Initiated";
$message = "What the subject says";
$from = "myemail@hotmail.com";

$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";

$headers .= "To: ".$to."\r\n";
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";

// and now we send it

mail($to, $subject, $message, $header);

// next, push the download as a binary file

$file = '/path/to/file-to-download.xyz';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);

// note:  pushing files can be accomplished in numerous ways.  The above may not be the best
// finally, redirect the user somewhere else

header("Location: http://www.yoursite.com/thanks.html");

?>
0
 
Jason C. LevineNo oneCommented:
Hi pigeonbr,

You would need to get a scripting language involved to accomplish what you are asking for and this type of request isn't part of the DW built-in server behaviors.  It's a relatively simple process to have a link that goes to a PHP (for example) page that contains nothing but a script that does the following:

1. fire off the email to you
2. send the headers out for a download and then push the file
3. redirect the user to a landing page

We would need to know more about your hosting setup and scripting experience to help you further.

0
 
pigeonbrAuthor Commented:
Ok, I see the idea of how to acomplish this. I'm not good in HTML, but could you give me a short code sequence that would , say, show me how to send an automated email to an email address (EX: myemail@hotmail.com) with the following Subject OR message text: "Download initiated" for example? Thanks!
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Jason C. LevineNo oneCommented:
Which language?  PHP?  ASP?  ColdFusion?
0
 
pigeonbrAuthor Commented:
jason, I'm not a web programmer...so either one of those is unfamiliar to me, but if you have some example I will study it...I'M a Visual C++ programmer by heart :) Just do some personal web stuff...nothing exotic so I never really need to learn much about PHP etc so far. Thanks for any help. Appreciate it. If you can't, that's ok as well. :)
0
 
RouchieCommented:
If you are a C++ programmer then I really recommend you use ASP.NET and the C# language, rather than PHP (Jason - you offence meant...!)

I use VB as part of ASP.NET (the other main choice) so I can only offer limited help, but there are TONS of books and online articles showing how to do an infinite number of server-side things with C#.

http://www.c-sharpcorner.com/1/send_mai1l.asp

If you're new to it all though, start at the beginning.  The good thing about ASP.NET is that you don't need to know about HTML because that is all written for you.
0
 
pigeonbrAuthor Commented:
Thanks jason...I will study this carefully. It points me in the direction I was lookng for.

Roucjie, thanks for your comment as well. I have way too much on my plate at this moment to get into learning new things, but thanks for the advice! Appreciate it for sure.

Thank you both!
0
 
Jason C. LevineNo oneCommented:
Rouchie,

I'm totally offended.

;)

Pigeonbr,

Ok, good luck.  I agree with Rouchie, though.  It will be an easier transition for you to go to ASP.NET than to PHP.  I didn't know you could embed C# via ASP.NET...
0
 
RouchieCommented:
>> I didn't know you could embed C# via ASP.NET...

There are TONS of languages you can choose from!  C# and VB are the most common, but the hardcore programmers are starting to use Python and Ruby.  

Here is a list http://www.dotnetpowered.com/languages.aspx  - PHP# is even on there, so now you've got to move over...!!

Given the extremely powerful object orientated approach (having the programming code in a seperate file that controls the page items' functionality), its a nice clean way to operate that keeps presentation away from the logic.

Reading that back anyone would think I work for Microsoft.  Totally not true, I still think their releases are all patch-tastic.
0
 
Jason C. LevineNo oneCommented:
>> PHP# is even on there, so now you've got to move over...!!

Not in this lifetime.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.