Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts

    Post PHP: Tell A Friend Script (very basic)

    This is a form which a user can fill in if they find your site interesting. (very basic)
    Code:
    <The Form>
    <form action="" 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>
    Code:
    <PHP Script>
    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:\nhttp://www.your_sites_address.com\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";
    }}
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #2
    Regular Coder
    Join Date
    Nov 2008
    Posts
    103
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thanks simple looks good feels good

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    usefull code, also can be modified abit to be changed to a contact form

  • #4
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello.

    Any how-to for dummies about how to use this code? It doesnt work for me, any help?

    Thanks!

  • #5
    Regular Coder
    Join Date
    Sep 2007
    Posts
    264
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dreamdreamer View Post
    Hello.

    Any how-to for dummies about how to use this code? It doesnt work for me, any help?

    Thanks!
    Your page should be set up like this
    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:\nhttp://www.your_sites_address.com\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";
    }}
    ?>
    
    <form action="" 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>

  • #6
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Textarea

    Does anybody know how to implement in this form <textarea> ?
    I want to use fallowing java-script code which automatically fills textarea with full page url nad I need for that a textarea with ID="message", but I am new in php

    <script type="text/javascript">
    $(document).ready(function() {
    var message = 'I thought that you would find this information very useful: ' + document.URL;
    $('#message').text(message);
    });
    </script>

    Thank you in advance!


  •  

    Posting Permissions

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