SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sendmail.php Missing something simple I know it.

    Hey all,

    I am trying to get my sendmail.php to send the name and phone number also but its just sending the comments.. I know its something super simple I am missing. Can someone please look and let me know what it is.

    Any help would be appreciated.

    PHP Code:
    <?php
    $to 
    "me@myemail.com";
    $subject "Contact Us Form";
    $name $_REQUEST['name'] ;
    $email $_REQUEST['email'] ;
    $phone $_REQUEST['phone'] ;
    $comments $_REQUEST['comments'] ;
    $headers "From: $email";
    $sent mail($to$subject$name$phone$comments$headers) ;
    if(
    $sent)
    {print 
    "Your mail was sent successfully"; }
    else
    {print 
    "We encountered an error sending your mail"; }
    ?>
    I would like it to be like this, but not sure how the html would look.

    PHP Code:
    <?php
     
    $yourname 
    $_POST['yourname'];
    $phone $_POST['phone'];
    $email $_POST['email'];
    $comments $_POST['comments'];
     
    $mailmsg "Users name is $yourname and phone number is $phone <br> email address :  $email <br> users msg: $comments";
     
    if(
    $_POST) {
     
    print 
    $mailmsg;
    //print function will show us did we really stored values from our FORM fields or not
    //mail('youremailaddress@gmail.com',"aj php form", $mailmsg);
     
    }
     
    ?>
    Thanks In Advance

    David

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    From php.net:
    Code:
    bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
    Your code:
    Code PHP:
    $sent = mail($to, $subject, $name, $phone, $comments, $headers) ;

    See anything wrong yet?

    Try:
    Code PHP:
    $sent = mail($to, $subject, '$name' . "\n" . '$phone' . "\n" . $comments, $headers) ;

  3. #3
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, When I tested the form, this is what I got in return in my email

    $name
    $phone
    Is this working?
    Thanks In Advance

    David

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by laflair13 View Post
    Thanks for the reply, When I tested the form, this is what I got in return in my email

    $name
    $phone
    Is this working?
    Ha woops. Haven't written in PHP in a while.. and I'm still tired..

    Code PHP:
    $sent = mail($to, $subject, $name . "\n" . $phone . "\n" . $comments, $headers) ;

    I didn't mean to wrap the variables, that turns them into strings...

  5. #5
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much, that did the trick. Now go get ya some coffee...lol
    Thanks In Advance

    David


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
  •