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

  • Home
  • SEARCH
  • 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 7041201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:37+00:00 2026-05-28T02:00:37+00:00

Ok, i have made a contact form. i need a php script to email

  • 0

Ok, i have made a contact form. i need a php script to email me the information. Here is what i have so far:

<?php
$emailSubject = 'Contact Form';
$webMaster = 'email-here';

$firstName = $_POST ['first_name'];
$lastName = $_POST['last_name'];
$emailAddress = $_POST ['email'];
$uploadFile = $_POST ['datafile'];
$questions = $_POST ['comments'];

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}

Ok, i have tried and tried to make one that will submit a uploaded file. i can not find anything. It is either to hard, or will not work. please help me.

Also, where it says:

['first_name'];

is that where i put my input name?

Also, i have a thank you page. It is called: thank_you.html i need that to show up after the form is sent!

  • 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-05-28T02:00:38+00:00Added an answer on May 28, 2026 at 2:00 am
    $to_name = stripslashes($_POST['to_name']);
    
    $from_name = stripslashes($_POST['from_name']);
    
    $subject = stripslashes($_POST['subject']);
    
    $body = stripslashes($_POST['body']);
    
    $to_email = $_POST['to_email'];
    
    $attachment = $_FILES['attachment']['tmp_name'];
    
    $attachment_name = $_FILES['attachment']['name']; 
    
    if (is_uploaded_file($attachment)) { //Do we have a file uploaded?
    
      $fp = fopen($attachment, \"rb\"); //Open it
    
      $data = fread($fp, filesize($attachment)); //Read it
    
      $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
    
        fclose($fp);
    
    }
    
    //Let's start our headers
    
    $headers = \"From: $from_name<\" . $_POST['from_email'] . \">\n\";
    
    $headers .= \"Reply-To: <\" . $_POST['from_email'] . \">\n\"; 
    
    $headers .= \"MIME-Version: 1.0\n\";
    
    $headers .= \"Content-Type: multipart/related; type=\\"multipart/alternative\\"; boundary=\\"----=MIME_BOUNDRY_main_message\\"\n\"; 
    
    $headers .= \"X-Sender: $from_name<\" . $_POST['from_email'] . \">\n\";
    
    $headers .= \"X-Mailer: PHP4\n\";
    
    $headers .= \"X-Priority: 3\n\"; //1 = Urgent, 3 = Normal
    
    $headers .= \"Return-Path: <\" . $_POST['from_email'] . \">\n\"; 
    
    $headers .= \"This is a multi-part message in MIME format.\n\";
    
    $headers .= \"------=MIME_BOUNDRY_main_message \n\"; 
    
    $headers .= \"Content-Type: multipart/alternative; boundary=\\"----=MIME_BOUNDRY_message_parts\\"\n\"; 
    
    
    
    $message = \"------=MIME_BOUNDRY_message_parts\n\";
    
    $message .= \"Content-Type: text/plain; charset=\\"iso-8859-1\\"\n\"; 
    
    $message .= \"Content-Transfer-Encoding: quoted-printable\n\"; 
    
    $message .= \"\n\"; 
    
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    
    $message .= \"$body\n\";
    
    $message .= \"\n\"; 
    
    $message .= \"------=MIME_BOUNDRY_message_parts--\n\"; 
    
    $message .= \"\n\"; 
    
    $message .= \"------=MIME_BOUNDRY_main_message\n\"; 
    
    $message .= \"Content-Type: application/octet-stream;\n\tname=\\"\" . $attachment_name . \"\\"\n\";
    
    $message .= \"Content-Transfer-Encoding: base64\n\";
    
    $message .= \"Content-Disposition: attachment;\n\tfilename=\\"\" . $attachment_name . \"\\"\n\n\";
    
    $message .= $data; //The base64 encoded message
    
    $message .= \"\n\"; 
    
    $message .= \"------=MIME_BOUNDRY_main_message--\n\"; 
    
    
    
    // send the message
    
    mail(\"$to_name<$to_email>\", $subject, $message, $headers); 
    

    http://icrontic.com/discussion/7019/php-email-form-with-attachments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive made a contact form and I need it to go to mulitple recipients.
I made a PHP script for a form, but dont't know how to get
I have a contact form that sends to my email and I recently got
I have made a class which a form can inherit from and it handles
Alright here is what I am attempting to do. I have a form written
I have a working contact form in Joomla however when the user submits the
Scenario: I have a contact form on my web app, it gets alot of
I have successfully made contact with the internet and parsed a few documents via
I have made an application which calls the phone's contact list but i want
I have some contact information, in which I wish to wrap the telephone number

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.