Results 1 to 7 of 7

Thread: Contact Form

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Contact Form

    Help Please

    I'm trying to get this to work what i need it to do is show the username thats been typed in the contact form to show in the body of the message with the comments. I have only added the $user at the top still needs to be put in the bottom half

    can anyone help me please.

    PHP Code:
    <?
    $name = $_POST['name'];
    $email = $_POST['email'];
    $user = $_POST['user'];
    $comment = $_POST['comment'];
    if ($name != ""){
        if ($comment != ""){
                if ($email != ""){
                    mail( "[email protected]", "Feedback From $name",
        "$comment", "From: $email" );
                    $feedback = "Comment Sent.";
                } else {
                    $feedback = "You have left one or more of the fields empty. Please go <a href=\"signup.html\">back</a> and make sure you enter information in every field.";
                }
        } else {
            $feedback = "You have left one or more of the fields empty. Please go <a href=\"signup.html\">back</a> and make sure you enter information in every field.";
        }
    } else {
        $feedback = "You have left one or more of the fields empty. Please go <a href=\"signup.html\">back</a> and make sure you enter information in every field.";
    }
    ?>


    <? echo "$feedback"; ?>
    Last edited by Jamie_Garland; Jul 24th, 2006 at 06:04 PM.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Contact Form

    try this
    PHP Code:
    $comment $_POST['user'] . "\n\r" $_POST['comment']; 
    You don't need the double quotes around the $comment in the mail function, its not needed.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Contact Form

    Where abouts in the code does this go

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Contact Form

    replace
    PHP Code:
    $comment $_POST['comment']; 
    with
    PHP Code:
    $comment $_POST['user'] . "\n\r" $_POST['comment']; 
    also check out the comments on http://uk.php.net/mail there is some good examples and is worth reading if you want to expand your code to send HTML emails.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Contact Form

    I did that but no luck

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Contact Form

    Im looking for a script like the one below.

    http://www.goodealhosting.com/signup.php

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Contact Form

    Quote Originally Posted by Jamie_Garland
    Where abouts in the code does this go
    You said the body of the message? What meesge? John has shown you how to append the username to a string. If you are unable to work out how to append it to another string, I suggest you quit now.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width