Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Contact Form, Email and Downloading Files

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #24588
    cbrails
    Member

    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!

    #56241
    ikthius
    Member

    use javascript to validate your contact form.

    once validated, have the script do the download and re-direct to the page you want.

    something like this:

    Code:
    HTML part

    onsubmit=”validate_and_download()”

    JS part— bear in mind it will never work, but the logcal part of it
    validate_and_download()
    {
    validate the form
    if (all_form_validated == true)
    {
    download file
    re-direct to new page;
    }
    }

    #56257
    cbrails
    Member

    Thanks for the responses guys. Sorry I didn’t include any code thus far, but I figured it might have been explanatory. Im using Chris’ contact form, both in terms of javascript validation and the PHP redirect.

    Code:


    And

    Code:
    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);
    if ($success){
    print ““;
    }
    else{
    print ““;
    }
    ?>

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

    #56269
    ikthius
    Member

    $success will send the mail, do you want to send the mail???

    how to download files with PHP, let me google that your you…http://lmgtfy.com/?q=php+download+files+

    #56291
    cbrails
    Member

    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.

    #56301
    ikthius
    Member
    "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???

    #56359
    cbrails
    Member

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.