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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:11:10+00:00 2026-06-13T06:11:10+00:00

It’s my first time trying to make a contactform. And I’ve got a few

  • 0

It’s my first time trying to make a contactform. And I’ve got a few problems
It’s works, I get the email, but I don’t get the name the name field with me in the email.

HTML:

<form method="post" name="contactform" action="scripts/contact.php">
<h3>Name</h3>
<input type="text" name="name">
<h3>Email Address</h3>
<input type="text" name="email">
<h3>Message</h3>
<textarea name="message"></textarea>
<br/><input class="submit" type="submit" value="Send Form">
</form>

PHP:

<?php
$to = "name@domane.com";
$subject = "Contact Us";
$name = $_POST['name'];
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $name, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "One of the field are not filled as requirred"; }
?>

$name is my problem. I’ve I have it in, the email comes from hostmaster@domane.com, If I delete it, everything works fine. But I wan’t the name to be sent to me. How?
Or should I do it completely different?

Also, if you leave all the fields blank, the “user” doesn’t get any error message, and a blank email is sent to me.

Hope you can help me. 🙂

  • 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-13T06:11:11+00:00Added an answer on June 13, 2026 at 6:11 am

    Michael Berkowski is correct. What you’ll need to do is add the name to your message’s body (not in the sense of the input name= attribute, rather the body of the email).

    Something like this:

    <?php
    $to = "name@domane.com";
    $subject = "Contact Us";
    $name = $_POST['name'];
    $email = $_POST['email'] ;
    $message = $_POST['message'] ;
    $headers = "From: $email";
    
    $body = "Name: $name\r\n";
    $body .= "Message: $message";
    
    $sent = mail($to, $subject, $body, $headers) ;
    if($sent)
    {print "Your mail was sent successfully"; }
    else
    {print "One of the field are not filled as requirred"; }
    ?>
    

    Revised:

    HTML:

    <form method="post" name="contactform" action="scripts/contact.php">
    <label for="name">Name</label>
    <input type="text" name="name" id="name" />
    <label for="email">Email Address</label>
    <input type="text" name="email" id="email" />
    <label for="message">Message</label>
    <textarea name="message" id="message"></textarea>
    <br/><input class="submit" type="submit" value="Send Form" />
    </form>
    

    PHP:

    <?php
    $name = $_POST['name'];
    $email = $_POST['email'] ;
    $message = $_POST['message'] ;
    
    $body = "Name: $name\r\n";
    $body .= "Message: $message";
    
    $to = "name@domane.com";
    $from = "automailer@mydomainname.com (Website Automailer)";
    $subject = "Contact Us";
    $headers =  "From: $from\r\n" .
            "Reply-To: $email ($name)";
    $sent = mail($to, $subject, $body, $headers) ;
    if($sent) { echo "Your mail was sent successfully"; }
    else { echo "One of the field are not filled as requirred"; }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

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.