SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    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 Code:
    <?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?

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    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>"
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    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>"
    That worked! Thanks for your help.

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I added name as below to see what happens...not knowing any better:

    PHP Code:
    $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?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •