Log in

View Full Version : Sharing Contact Form



jickpictures
07-30-2010, 02:15 AM
Hey,

I need to make a contact form that allows users to type in someone else's email address and already has subject and body text filled out by me. I want them to also be able to type a personal message as well. Then once they click submit, it sends the email to the email address they typed in.

I have no idea how to do this though. If you can help me that'd be great, I'm struggling over here. Thank you so much.

Ryan

bluewalrus
07-30-2010, 02:18 AM
Can you post what you have for html? Is the text varying by the email address entered?

jickpictures
07-30-2010, 02:25 AM
God I love everyone on dynamic forums you guys answer so fast. I will be displaying it in a pop up window with a jQuery script called Boxy (http://onehackoranother.com/projects/jquery/boxy/). Once a link is clicked with Boxy, it opens up a small web page. Unfortunately, you can't code it like a normal HTML page with div id's and external CSS or anything, it has to be within one div layer. Like this:


<div style='background-color:#232323; height: auto; width: 400px; padding: 10px; color: #666; font-size: 10px'>
EMAIL FORM GOES HERE
</div>


Have you ever tried to share a video on youtube through email? That's what I want. I want someone to enter in an email address of their friends. Then the email sends to the email address they entered. I'm not exactly sure what you mean about they "text varying".

fastsol1
07-30-2010, 03:32 AM
This is pretty much the same thing as a "Share this page with a friend" This is what I use. Now you'll have to modify it to work in your situation, but I don't think that should be to hard.


<form action="refer.php" method="post">
<p>Page you are sending:
<?php $fullurl = $_SERVER['HTTP_REFERER'];
echo "<a href='$fullurl'>$fullurl</a>" ;
echo"<input type='hidden' name='link' value='$fullurl'>";?>
<br>
<br>
</p>
<table width="50%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td width="50%">Friend's&nbsp;Name:</td>
<td width="50%">
<input type="text" name="name" class="formbox">
</td>
</tr>
<tr>
<td>Friend's&nbsp;E-mail:</td>
<td><input type="text" name="email"class="formbox" ></td>
</tr>
<tr>
<td>Your&nbsp;Name:</td>
<td><input type="text" name="sendername" class="formbox"></td>
</tr>
<tr>
<td>Your&nbsp;E-mail:</td>
<td><input type="text" name="senderemail" class="formbox"></td>
</tr>
</table>
<p> Your Message:<br>
<textarea name="message" cols="50" rows="5" class="formbox"></textarea>
<br>
<input type="submit" name="submit" value="Send Page" class="btn">
<input type="reset" value="Reset" class="btn">
<input type="button" value="Back to Page" class="btn" onClick="history.go(-1)">
</p>
</form>

refer.php


<?php
if(isset($_POST['submit'])) {
$headers = 'From: System Admin <noreply@domain.com>';
$to = $_POST['email'];
$sendername = $_POST['sendername'];
$senderemail = $_POST['senderemail'];
$name = $_POST['name'];
$email = $_POST['email'];
$link = $_POST['link'];
$message = $_POST['message'];
$signature = "Thank You, ";
$from = "Share-This-Page@yourpage.com";
$subject = "$sendername thought you might like this page!";
$body = "Hi $name, $sendername at $senderemail thought you might be interested in the page found at $link\r\nThey wrote the following message for you:\r\n $message";
mail($to, $subject, $body, "From: $from");

echo "<div align=\"center\"><table width=\"96%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ";
echo "style=\"font-size:11pt;font-color:black;\">";
echo "<tr height=\"40\" align=center><td><p>&nbsp;</p></td></tr>";

echo "<tr><td >An e-mail was sent to $name (<a href=\"mailto:$email\">$email</a>), We hope they will enjoy the page at";
echo " <a href=$link target=_blank>$link </a><br><br>Your message was:<br>$message";
echo "<CENTER><FORM><INPUT type='button' value='Back to Page' class='btn' onClick='history.go(-2)'></FORM></CENTER>";
echo "</td></tr></table></div>";
}
else echo "You shouldn't link to this page directly";
?>

jickpictures
07-30-2010, 04:23 PM
Works beautifully fastsol1. Thank you! Is there anyway to make an image appear in email? Also how do you make the message text the user typed to appear bold. I see that the \r\n code works the same as breaks <br>. Is there a code like that to make text bold?

fastsol1
07-30-2010, 04:43 PM
To use html tags in the email you need to change the email header type to something like this
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Your domain.com";

Then you can format the entire email with images and stuff using table layout, I don't think you can use divs but I could be wrong on that, I found tables to be easiest for emails
Here's an example of a tabled email with images, remember to do an absolute url to the images though.

$body = "<table id='Table_01' width='500' height='303' border='0' cellpadding='0' cellspacing='0'align='center' style='background-color:#000000'><tr><td colspan='3'><img src='http://remotelystartedmn.com/images/email/rsmn-email-layout-01.jpg' width='500' height='149' alt='' /></td></tr><tr><td style='width:19px'></td><td><table cellpadding='0' cellspacing='0' style='width:463px;height:135px; background-color:#000000;font-family: arial;color: silver;'><tr><td style='vertical-align:top;padding-bottom:20px;'><b>Dear ".$_GET["name_$x"]."</b><br/><br/><p>$message</p></td></tr><tr><td><p style='color:#ffffff;font-size:10px;text-align:center'>If you no longer want to receive email specials or promotions from me you may <a href=' http://remotelystartedmn.com/unsubscribe.php?to=$to '>Unsubscribe</a></p></td></tr></table></td><td style='width:18px'></td></tr><tr><td colspan='3'><img src='http://remotelystartedmn.com/images/email/rsmn-email-layout-05.jpg' width='500' height='19' alt='' /></td></tr></table>";

jickpictures
07-30-2010, 04:49 PM
So helpful man thank you so much. Exactly what I needed.

fastsol1
07-30-2010, 05:03 PM
No problem!

jickpictures
07-30-2010, 06:04 PM
Fastsol1, For some reason the HTML is just showing up as text in my email client. The PHP is working fine though. Here is my PHP:


<?php
if(isset($_POST['submit'])) {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Jick Pictures";
$to = $_POST['email'];
$sendername = $_POST['sendername'];
$senderemail = $_POST['senderemail'];
$name = $_POST['name'];
$email = $_POST['email'];
$link = $_POST['link'];
$message = $_POST['message'];
$signature = "Thank You, ";
$from = $_POST['senderemail'];
$subject = "$sendername shared a Jick Flick with you!";
$body = "<table id='Table_01' width='600' height='303' border='0' cellpadding='0' cellspacing='0'align='center' style='background-color:#fff'><tr><td colspan='3'><img src='http://www.jickpictures.com/emailimages/toplogo.jpg' width='600' height='100' alt='' /></td></tr><tr><td style='width:19px'></td><td><table cellpadding='0' cellspacing='0' style='width:550px;height:135px; background-color:#fff;font-family: arial;font-size:12px;color: #333;'><tr><td style='vertical-align:top;padding-bottom:20px;'><b>Sup, $name!</b><br/><br/><b>$sendername</b> thought you might like this video from Jick Pictures! You can check it out here: $link<br /><br />They also left you a message:<br /><br /><i>$message</i></p></td></tr><tr><td><p style='color:#000;font-size:10px;padding-bottom:10px;text-align:center'>Jick - We make short movies for short attention spans. Spread the word! <a href='ttp://twitter.com/home?status=Check+out+these+cool+movies+at+Jick+Pictures!%21+http%3A%2F%2Fwww.jickpictures.com' style='color: #708fa2'>Twitter</a> | <a href='http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jickpictures.com' style='color: #708fa2'>Facebook</a></p></td></tr></table></td><td style='width:18px'></td></tr><tr><td colspan='3'><img src='http://www.jickpictures.com/emailimages/bottom.jpg' width='600' height='19' alt='' /></td></tr></table>"; mail($to, $subject, $body, "From: $from");


echo "<div align=\"center\"><table width=\"96%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ";
echo "style=\"font-size:12px;font-color:#666;\">";
echo "<tr height=\"10\" align=center><td><p>&nbsp;</p></td></tr>";

echo "<tr><td >An e-mail was sent to $name (<a href=\"mailto:$email\">$email</a>), You know their gunna love the Jick Flick at";
echo " <a href=$link target=_blank>$link </a><br><br>Your message was:<br>$message";
echo "</td></tr></table><br></div>";
}
else echo "You shouldn't link to this page directly";
?>

You can see for yourself and test it out here at: http://www.jickpictures.com/preview. Just click on the "Extras" drop down menu and click on "Email".

Can you see whats wrong?

fastsol1
07-30-2010, 06:13 PM
Replace this

mail($to, $subject, $body, "From: $from");
With this

mail($to, $subject, $body, $headers);