Results 1 to 6 of 6

Thread: php mail form

  1. #1
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question php mail form

    I have forms on a website that I want my php to return information in the email.
    Here is the php:

    <?php

    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $date = $_REQUEST['date'] ;
    $comments = $_REQUEST['comments'] ;

    if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.c1realty.com/temp/pm/mreq.htm" );
    }

    elseif (empty($name) || empty($phone) || empty($date) || empty($email)) {
    header( "Location: http://www.c1realty.com/temp/error.htm");
    }


    else {
    mail( "info@c1realty.com", "Web Maintenance Request Form",
    $comments, "From: $name <$email>" );
    header( "Location: http://www.c1realty.com/temp/thanks.htm" );
    }

    ?>

    When the email is sent to the mailbox of info@c1realty.com I want it to also include the comments, phone number, date so this information is supplied in the email.

    I can get it to work using $comments, or $phone, or $date, but I cannot get it to work if I combine them for instance
    $comments, $phone, $date, "From: $name <$email>" );

    I know there must be a way to do this, but I have not been able to figure it out. Can someone help?

    Thanks
    cyndie

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    PHP Code:
    <?php

    $to 
    "info@c1realty.com";
    $subject "Web Maintenance Request Form";
    $message "";
    $from trim(strip_tags($_REQUEST['email']));

    foreach(
    $_REQUEST as $key => $val)
    {
          
    $message .= $key .": "trim(strip_tags($val)) ."\n";
    }

    if( !
    mail($to$subject$message"From: $from") {
       
    header("Location: http://www.c1realty.com/temp/error.htm");
    }
    else {
       
    header("Location: http://www.c1realty.com/temp/thanks.htm");
    ?>
    that will populate the "body" of the email with everything that has been sent via the form...

  3. #3
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks I'll try this.
    Cyndie

  4. #4
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Still not working

    Thanks for the response boogeyman. however when testing on my server it does not redirect to the Thank you page and never sends the email.

    Is there something in this php file I need to edit?

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if( !mail($to, $subject, $message, "From: $from") {
    ...
    }
    else {
    ...
    lovely typo's
    Code:
    if( !mail($to, $subject, $message, "From: $from") ) {
    ...
    }
    else {
    ...
    }

  6. #6
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Boogyman, works like a charm!

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
  •