Contact Form, Email and Downloading Files
# April 13, 2009 at 11:09 pm
Okay, so I downloaded the contact form php script and copied the parameters. I have it working, but now I want to modify it, and Im not sure how to go about it. Basically what I want to do is create a form that the user has to fill out (and won’t submit without validating), and then the submit button performs two functions. It will download a zip file onto their hard drive as well as redirect them to a different page (or back to the index page, Im not picky). I can make the page redirect to another, or download the file. But once it downloads the file, it is sitting on an empty page, if I just point the redirect straight to the zip file. So how can I make it perform both functions? Any help would be greatly appreciated. Thanks in advance!# April 14, 2009 at 2:11 am
This reply has been reported for inappropriate content.
when asking code questions, you should always post your code. a lot of times it might be a simple matter of making one little change to your code. Without seeing your code, No no one can make that change. Most people won’t want to sit here and right out the entire program.
I would think all you would need to do is throw in an elseif statement.# April 14, 2009 at 2:16 am
once validated, have the script do the download and re-direct to the page you want.
something like this:Code:HTML part
JS part— bear in mind it will never work, but the logcal part of it
validate the form
if (all_form_validated == true)
re-direct to new page;
}# April 14, 2009 at 9:40 am
AndCode:// send email
$success = mail($EmailTo, $Subject, $Body, “From: < $EmailFrom>“);
. Obviously the PHP is only the latter half of the code, but my main problem is just knowing what to add to the code to make it do the download. Im not completely familiar with PHP as a coding language, so Im not sure how to make it do both. Im assuming it requires writing one more piece in the if ($success) section, but I don’t know what.# April 15, 2009 at 2:35 am"cbrails" wrote:I want to do both, as I had stated. I want it to download the file AND send the e-mail. I wasn’t sure if I had to say each separately, or if I could do them in one statement. That’s about as far as I got.
when you call the mail script it runs, so if you call another script before the mail script (the whole file not just te mail function) that file will run, when the new script completes its job, the mail script will resume.
so yes it is possible, you just need to look inot the file handlers of PHP, or search for a php download file script. or why dont you email them the file???# April 15, 2009 at 9:06 pm
Im looking into file download scripts as per your suggestion. I want the e-mail to go to my client, but the file to be downloaded by the customers on his page. Basically, the information the customers fill out will be in the e-mail, and they must submit it in order to download the file. I can try to mash up the two scripts together, but I just wasn’t sure how to successfully put both together. Perhaps when I get to that point, I’ll post it here and see what else needs to happen.
You must be logged in to reply to this topic.