Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-27-2008, 10:10 PM   PM User | #1
student101
Regular Coder

 
student101's Avatar
 
Join Date: Nov 2007
Posts: 610
Thanks: 80
Thanked 13 Times in 13 Posts
student101 is on a distinguished road
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:
student101 is offline   Reply With Quote
Old 11-13-2008, 07:28 AM   PM User | #2
bijaybd
New Coder

 
Join Date: Nov 2008
Posts: 99
Thanks: 4
Thanked 0 Times in 0 Posts
bijaybd has a little shameless behaviour in the past
thanks simple looks good feels good
bijaybd is offline   Reply With Quote
Old 11-14-2008, 10:03 AM   PM User | #3
hip_hop_x
New Coder

 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
hip_hop_x is an unknown quantity at this point
usefull code, also can be modified abit to be changed to a contact form
hip_hop_x is offline   Reply With Quote
Old 01-19-2010, 12:06 AM   PM User | #4
Dreamdreamer
New to the CF scene

 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Dreamdreamer is an unknown quantity at this point
Hello.

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

Thanks!
Dreamdreamer is offline   Reply With Quote
Old 01-19-2010, 04:46 AM   PM User | #5
IFeelYourPain
Regular Coder

 
Join Date: Sep 2007
Posts: 250
Thanks: 19
Thanked 0 Times in 0 Posts
IFeelYourPain has a little shameless behaviour in the past
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>
IFeelYourPain is offline   Reply With Quote
Old 12-11-2012, 08:49 AM   PM User | #6
luxpc
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
luxpc is an unknown quantity at this point
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!
luxpc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Advertisement
Log in to turn off these ads.