Submiting form to email addy via PHP

Discussion in 'Programming' started by Wynnefield, Mar 21, 2005.

to remove all ads.
  1. Wynnefield

    Wynnefield New Member

    Messages:
    48
    i was reading a php resource book at B&N last week or two, and it had some great examples of submitting a form to a .php page to route to an email address and display an echo message to the web visitor ...

    any examples would be much appreciated ... thank you
     
  2. Chroder

    Chroder New Member

    Messages:
    194
  3. Wynnefield

    Wynnefield New Member

    Messages:
    48
    thank you chroder ... i will check it out
     
  4. Wynnefield

    Wynnefield New Member

    Messages:
    48
    not much help from the site ... i found a book today with the perfect code snippets; however, after submitting the button on the contact.html page with <form action="contact.php" method="post"...>, i receive:

    "parse error, unexpected T_STRING, expecting ']' .../contact.php on line 63"

    the line referred to in the error is the $formsent = mail (...) line in the following code in contact.php:

    <?php
    /* receive and email form data from contact.html */
    $name = $_POST['contact_name'];
    $company = $_POST['contact_company'];
    $email = $_POST['contact_email'];
    $phone = $_POST['contact_phone'];
    $subject = $_POST['contact_topic'];
    $comments = $_POST['contact_comments];
    $formsent = mail('[email protected]', $subject, $comments);
    if ($formsent)
    {echo "Thank you, $name. We have received your comments, and will respond with the next 48 hours.";}
    else
    (echo "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.";)
    ?>

    PLEASE HELP!! ... thank you (the winkie face is actually a ";" and ")" in the php code)
     
  5. Chroder

    Chroder New Member

    Messages:
    194
    Use bbcode to post code.

    Anyway,
    Code:
     else
    (echo "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.");
    Is incorrect, replace with:

    PHP:
    else
    {
        echo 
    "We are currently experiencing problems with our contact form and apologize for any inconvenience. Please try again at your convenience.";
    }
     
  6. Wynnefield

    Wynnefield New Member

    Messages:
    48
    thank you for the posting hint ... do you have any idea how to resolve my error??
     
  7. Chroder

    Chroder New Member

    Messages:
    194
    Ah yes,

    PHP:
     $comments $_POST['contact_comments];
    You are missing a quote.

    PHP:
     $comments $_POST['contact_comments'];
     
  8. Wynnefield

    Wynnefield New Member

    Messages:
    48
    oh my gosh! have you every looked at a piece of code for so long, you just can't see it right in front of your face???? ... thank you chroder

    i owe ya one! ...
     
  9. Chroder

    Chroder New Member

    Messages:
    194
    If you post it into the [php ] bbcodes, you can easily tell the missing quote ;)

    Try getting an editor with syntax highlighting, too. Like PHP Designer (free) or EditPlus (free eval).
     
  10. Wynnefield

    Wynnefield New Member

    Messages:
    48
    i am surprised DW didn't catch it. the way i have been staring at my laptop during the last few weeks, it may have and i just didn't see the error ... anyway, thank you again. look for my new site in the review section later this week ... would love feedback from fellow designers ... wynne
     

Share This Page