Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:17:45+00:00 2026-06-11T04:17:45+00:00

I have been trying to find a way to attach the html form as

  • 0

I have been trying to find a way to attach the html form as well as the file attachment through php. The aim is when the user press submit button, both the HTML form (with visible fields only) and the file attachment (uploaded) are attached as email. This is a kind of HTML email but I want the HTML form attached in the email. I am unable to find any solution ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:17:47+00:00Added an answer on June 11, 2026 at 4:17 am

    You want to send the form values as an attachment instead of in the actual body text of the email? If so, you could create an html page with the data of the form and save it on your server. Then, send it. Let me know if you need help and I’ll post some code. I don’t recommend this approach very much, however. You should be sending it in the body text of the email, in my opinion.

    Create the file:

    $fh = fopen($filename, 'w') or die("can't open file");
    fwrite($fh, '<html><body>');
    fwrite($fh, "<h1>$title</h1>$text");
    fwrite($fh, '</body></html>');
    fclose($fh);
    

    Send the file via php mailer:

    $mail->AddAttachment($whereEverYouSavedYourFile, $whatEverYourFileNameIs);
    

    Try it and post code if it doesn’t work (probably a new question with your specific problem).

    Edit:

    To send email with post data, make you form submit to a PHP page with this in it:

    <?php
    
    // get and sanitize post data like this
    // note: you must have a form field with a 'name' of 'firstName' and on of 'lastName'
    $firstName = htmlspecialchars($_POST['firstName'], ENT_QUOTES, 'UTF-8');
    $lastName = htmlspecialchars($_POST['lastName'], ENT_QUOTES, 'UTF-8');
    
    // put the data in a new variable
    $body = <<<HTML
      First name: $firstName \r\n
      Last name: $lastName \r\n
    HTML;
    
    // send mail
    mail('whoEver@theirEmailAddress.com', 'form data', $body);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to find a way of getting a windows batch file
I have been looking through trying to find some way to redirect to an
I have been trying for hours to find a way to solve the issue,
I've been trying to find a way to do this but, have not found
I have been trying for the last week to find a way to make
I have been trying to find a way to get Clang working on Windows
I have been trying to find a way to do this query using a
I have been trying to find a way to incorporate something similar to Closure
I have been trying to find a way of watermarking all .jpg files in
I have been trying to find a way to set variables for one class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.