Back Home

Open Designs

Community. Driven.

    •  
      CommentAuthorcoll23
    • CommentTimeDec 19th 2006
     
    Hello all, I'm not too famaliar with "back end" stuff and I am trying to implement a feedback form for a friend's website...so far I have found script through a google search that allows me to post a message to my friends e-mail, but I want it to include more variables. So far here's what i have:
    HTML-

    <form method="post" action="sendmail.php">
    Email: <input name="email" type="text" /><br />
    Message:<br />
    <textarea name="message" rows="15" cols="40">
    </textarea><br />
    <input type="submit" />
    </form>

    PHP-

    <?
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "yourname@example.com", "Feedback Form Results",
    $message, "From: $email" );
    header( "Location: http://www.example.com/thankyou.html" );
    ?>
    What I would like to do is have a couple more form details, namely, The senders name and phone number. So far I can only send the message text and the senders e-mail naturally shows up in the "from" field in the inbox. Any thoughts? or a good place for tutorials would be greatly appreciated.
    coll23
    •  
      CommentAuthorbcwood
    • CommentTimeDec 19th 2006 edited by bcwood on the 19th December 2006 at 08:20:51 EST
     
    All you have to do is append the other fields to the message of the email. In your form, just add whatever other fields you want to capture:

    Name: <input name="name" type="text" /><br />
    Phone #: <input name="phone" type="text" /><br />

    Then in your PHP script, append these values to the end of the email message:

    $message = $_REQUEST['message'] ;
    $message .= "<br />Name: " . $_REQUEST['name'] ;
    $message .= "<br />Phone #: " . $_REQUEST['phone'] ;

    I think this should do it for you, let me know if not...
  1.  
    •  
      CommentAuthorcoll23
    • CommentTimeDec 19th 2006
     
    Hey thanks Brandon,
    I tried it a couple times and still just get the message text showing up in the e-mail...here is the updated HTML:

    <form method="post" action="sendmail.php">
    <label>Name</label>
    <input name="name" type="text" />
    <label>Email</label>
    <input name="email" type="text" />
    <label>Phone Number</label>
    <input name="phone" type="text" />
    <label>Questions/Details of Project:</label>
    <textarea name="message" rows="15" cols="40"></textarea>
    <input type="submit" />
    </form>

    maybe I'm just messing up the PHP code or not putting it in the right spot. Here's what i got:

    <?
    $message .= "<br />name: " . $_REQUEST['name'] ;
    $message .= "<br />phone #: " . $_REQUEST['phone'] ;
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "yourname@example.com", "Feedback Form Results",
    $message, "From: $email");

    header( "Location: http://www.example.com/thankyou.html" );
    ?>

    Again this is all pretty new to me!
    •  
      CommentAuthorcoll23
    • CommentTimeDec 19th 2006
     
    Thanks for the link Christopher!
    •  
      CommentAuthorbakercad
    • CommentTimeDec 19th 2006 edited by bakercad on the 19th December 2006 at 08:59:03 EST
     
    PHP part should look like this:
    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $message .= "<br />name: " . $_REQUEST['name'] ;
    $message .= "<br />phone #: " . $_REQUEST['phone'] ;

    mail( "yourname@example.com", "Feedback Form Results",
    $message, "From: $email");

    header( "Location: http://www.example.com/thankyou.html" );
    ?>
    •  
      CommentAuthorcoll23
    • CommentTimeDec 19th 2006
     
    Thank you everyone!...thanks for the updated script Bob, everything is working now! cheers.
    collin
    •  
      CommentAuthorjanpd24
    • CommentTimeDec 19th 2006
     
    Or you could use this Clever Little PHP Form which a friend made for me. It's got a "security" feature of sorts! The form, processing script and the "thank you" page are all incorporated in one file.