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 5957457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:24:11+00:00 2026-05-22T18:24:11+00:00

I am using the script below to return an email with the submitted fields

  • 0

I am using the script below to return an email with the submitted fields to my email address.

I have recently found the need to have a confirmation email sent to who ever submitted the form in the first place but am unsure on how to alter the script. I basically need it to say something like “Dear $name, Thanks for contacting us….”.

Please can someone help?

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Website Enquiry';

// Your email address. This is where the form information will be sent.
$emailadd = 'myemail@myemail.co.uk';

// Where to redirect after form is processed.
$url = 'thanks.php';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "WEBSITE ENQUIRY:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

The script allows for any form element to be sent in the email without the need of including it within the php script.

The email address is collected in the html

<span class="input">
  <input type="text" name="Email" id="Email"/>
  </span>

and the name…

<span class="input">
    <input type="text" name="Name" id="Name" />
 </span>

Many thanks

Craig

  • 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-22T18:24:12+00:00Added an answer on May 22, 2026 at 6:24 pm

    This code will send a confirmation to the user who submitted the form, but it doesn’t check to make sure they’ve entered a valid email address. There’s a handy script at isemail.info which will validate that for you.

    Insert the code just above the ---Do not edit below this line--- line.

    // Subject of confirmation email.
    $conf_subject = 'Your recent enquiry';
    
    // Who should the confirmation email be from?
    $conf_sender = 'Organisation Name <no-reply@myemail.co.uk>';
    
    $msg = $_POST['Name'] . ",\n\nThank you for your recent enquiry. A member of our 
    team will respond to your message as soon as possible.";
    
    mail( $_POST['Email'], $conf_subject, $msg, 'From: ' . $conf_sender );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PHP and I need to script something like below: I have
I am using the following script below. The email gets sent correctly except the
I have tested the below script on a demo page which is not using
I have a small script which im using to test PHP mail(), as below:
I am using below statement to return the directory name of the running script:
The script below worked on my Mac OS X. I'm now using Ubuntu OS,
I want to enable auto update script in flex3. i am using below code
Just starting using the Firebug console. I have a test script which I'll post
I am working on a comment script using ajax, json and jquery. I have
I have this form that is using data-defaults and I need to be sure

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.