Sendmail script problem

Hi,

I’m trying to work out how to send data from a contact form to email with no knowledge of PHP.

I’ve copy/pasted some code and am going OK so far. I’m receiving the emails with the email address and message, but I don’t receive the name? I’ve tried a few things but cant’ work out where to put what…

Below is the form code:

<form method="post" action="sendmail.php">
      	<dl class="contained tabs">
        <dd class="active"><a href="#contactForm">Contact Us</a></dd>
      </dl>
      <ul class="tabs-content contained">
      	
        <li id="contactFormTab" class="active">
          <div class="row collapse">
            <div class="two columns"><label class="inline">Your Name</label></div>
            <div class="ten columns"><input type="text" placeholder="Your Name" name="name" />
          </div>
          <div class="row collapse">
            <div class="two columns"><label class="inline">Your Email</label></div>
            <div class="ten columns"><input type="text" placeholder="Your Email" name="email" />
          </div>

          <label>Your Inquiry</label>
          <textarea rows="4" name="message"></textarea>
          <button type="submit" class="radius button">Submit</button>
        </li>

        </ul>
</form>

And here is the PHP:

<?php
  $name = $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "email address", "Feedback Form Results",
  	$message, "From: $email" );
  header( "Location: thankyou page" );
?>

Do I need to add something in the 7th line of the PHP code?

mail( “email address”, “Feedback Form Results”,
$message, “From: $email” );

Where in there did you put $name ?

I -think what you’re trying to do would require a quick reformat of that From header…

“From: $name <$email>”

I added name as below to see what happens…not knowing any better:


$message, "From: $name, $email" );

I now get the name instead of the email address in the from field and receive the contents of the message in the body of the email.

I might search for another script as this one is pretty basic right?

That worked! Thanks for your help.