#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0

    Tell a friend with teaxtarea!


    Does anybody know how to implement in this form <textarea> ?
    Code:
    http://imgur.com/dt1ap
    PHP Code:
     <?php
    if (isset($_POST['Submit'])) {
    // This will check to see if the form has been submitted
    $senders_email $_POST['your_email'];
    // The person who is submitting the form
    $recipient_friend $_POST['friend_email'];
    // The forms recipient
    mail($recipient_friend,"A message from $senders_email""Dear $recipient_friend,\n\nYour friend $senders_email, found our site very useful, and thought you would be interested.\n\nPlease follow the link to view our site:\n(URL address blocked: See forum rules)\n\nThank You\n\nThe your_sites_address.com"'From: "your_site" <your_email.com>');

    if (isset(
    $_POST['your_email'])) {
    echo 
    "<br>Your friend $recipient_friend has been contacted <br><br>Thank you $senders_email";
    }}
    ?>
    Code:
    <form action="tell_a_friend.php" method="POST">
    <fieldset>
    <legend>Tell a friend</legend><br />
    Your email<br />
    <input type="text" name="your_email" value="Your email" /><br /><br />
    Your Friends email<br />
    <input type="text" name="friend_email" value="Your friends email" />
    <input type="Submit" value="Tell a friend" name="Submit" />
    </fieldset>
    </form>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,230
    Rep Power
    593
    Looks like you already have. What is not working?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by gw1500se
    Looks like you already have. What is not working?
    yes in html I know how to add this field but I do not know how to include its value in the email (php)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,230
    Rep Power
    593
    The same way you include any other value. You use $_POST with the name of the textarea (which you don't seem to have in your form).
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    Look at what you have:

    <input type="text" name="your_email" value="Your email" /><br /><br />


    Then in PHP:

    $senders_email = $_POST['your_email'];


    Do you see how the input name is the same as the post array key? That's how you do it. Give your input a name.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by ManiacDan
    Look at what you have:

    <input type="text" name="your_email" value="Your email" /><br /><br />


    Then in PHP:

    $senders_email = $_POST['your_email'];


    Do you see how the input name is the same as the post array key? That's how you do it. Give your input a name.
    I have tried to do that but it doesn't work for me

    my version ():

    I includet in html:

    Code:
    <textarea id="message" name="url">
    Your text here
    </textarea>
    And in php I included this code:

    Code:
    $message = $_POST['url'];

    then I included this in mail body

    Code:
    mail($recipient_friend,"A message from $senders_email", "Dear $recipient_friend,\n\nYour friend $senders_email, $message found our site very useful, and thought you would be interested.\n\nPlease follow the link to view our site:\n(URL address blocked: See forum rules)\n\nThank You\n\nThe your_sites_address.com", 'From: "your_site" <your_email.com>');

    But it doesn't work
  12. #7
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    This is how you debug:

    1) Are you sure the textarea is named properly and properly formed? Inspect it in firebug or chrome inspector to see if those tools have a "name" attribute with "url" as the value.

    2) If it is, make sure it's being included in the POST data. print_r($_POST) in your PHP to dump the post data to the screen, see if it's present.

    3) If it's present, ensure your variable assignment is working. Echo $message before sending the email.

    4) If $message is correct, double-check the spelling of your variables inside the mail() call. If they're correct, pull the entire email body out of that function call and make it a variable, then echo THAT to the screen as well.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by ManiacDan
    This is how you debug:

    1) Are you sure the textarea is named properly and properly formed? Inspect it in firebug or chrome inspector to see if those tools have a "name" attribute with "url" as the value.

    2) If it is, make sure it's being included in the POST data. print_r($_POST) in your PHP to dump the post data to the screen, see if it's present.

    3) If it's present, ensure your variable assignment is working. Echo $message before sending the email.

    4) If $message is correct, double-check the spelling of your variables inside the mail() call. If they're correct, pull the entire email body out of that function call and make it a variable, then echo THAT to the screen as well.

    Code:
     data. print_r($_POST)
    where should I search for it?


    Can you please edit the existing code to make it work ok and submit here ? There are hundreds of scripts on the internet with tell a friend functions but they either do not work or doesn't have a text area. This one is perfect one it is so speedy and do not fall in spam box.

    Please modify it for us , newbies
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,230
    Rep Power
    593
    Since you didn't post existing code we can't. However, 'data.' is the end of ManiacDan's prevous sentence not part of the code. Anywhere before your first use of $_POST add this:
    PHP Code:
    echo "<pre>";
    print_r($_POST);
    echo 
    "</pre>"
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  18. #10
  19. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    Since you got to step 2, I assume you did step 1. gw is correct, I meant the code he said. Then, what you would search for, is the variable in question. In this case, an entry for "url" in the resulting printed array.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo