Hi,
I've created a tellafriend form for a CMS. I need some hidden fields in the form so that I can pass homepage address, link to logo, and the web admin email address. However, the value of the hidden fields is not passed to my mail file. You could also try the form on my website http://www.zoosh.me/tellafriend.php Is there a bug in php or something is wrong with my files? I would really appreciate your help guys.
Thanks, Ovi
<form id="tellafriend" method="post" action="mail.php">
<fieldset>
<img id="telllogo" width="170" alt="Logo" src="/perch/resources/1253956138myself-w170.jpg"/>
<input width="170" type="hidden" alt="Logo" value="/perch/resources/1253956138myself-w170.jpg" name="logo"/>
<input type="hidden" value="http://www.zoosh.me" name="webaddress"/>
<ul class="wrapper">
<li>
<label class="label" for="yourname">Your Name:</label>
<input id="yourname" class="text jquery-live-validation-on invalid" type="text" value="" name="yourname"/>
<img alt="Invalid" src="images/invalid.png"/>
</li>
<li>
<label for="youremail">Your Email:</label>
<input id="youremail" class="text jquery-live-validation-on invalid" type="text" value="" name="youremail"/>
<img alt="Invalid" src="images/invalid.png"/>
</li>
<li>
<label for="friendsname">Friend's Name:</label>
<input id="friendsname" class="text jquery-live-validation-on invalid" type="text" value="" name="friendsname"/>
<img alt="Invalid" src="images/invalid.png"/>
</li>
<li>
<label for="friendsemail">Friend's Email:</label>
<input id="friendsemail" class="text jquery-live-validation-on invalid" type="text" value="" name="friendsemail"/>
<img alt="Invalid" src="images/invalid.png"/>
</li>
<li>
<label for="message">
Your Message
<br/>
<small id="charLeft">150 Characters left</small>
</label>
<textarea id="message" class="jquery-live-validation-on invalid" cols="10" rows="3" name="message"/>
<img alt="Invalid" src="images/invalid.png"/>
</li>
<li class="inputSubmit">
<input id="submit" class="submit" type="submit" value="Send"/>
</li>
</ul>
<input type="hidden" value="[email protected]" name="adminaddress"/>
</fieldset>
</form>
Here is the code for the mail.php file that processes the form and sends an email to my visitor's friends.
<?php
$yourname = $_POST['yourname'];
$youremail = $_POST['youremail'];
$news = $_POST['news'];
$friendsname = $_POST['friendsname'];
$friendsemail = $_POST['friendsemail'];
$adminemail = $_POST['adminemail'];
$logo = $_POST['logo'];
$webaddress = $_POST['webaddress'];
$subject = "I've found a great website!";
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: " . strip_tags($from) . "\r\n";
$headers .= "BCC: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = $_POST['message'];
$body="<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Zoosh</title>
</head>
<body>
<table width='90%' cellpadding='0' cellspacing='0'>
<tr>
<td align='center' valign='top'>
<table width='411' cellpadding='0' cellspacing='0'>
<tr>
<td><img src='http://recycledoc.com/emails/zoosh_tellafriend/tdbg.png' width='1' height='450' alt='Tdbg'></td>
<td background='http://recycledoc.com/emails/zoosh_tellafriend/tellafriendbg.jpg' valign='top' style='padding-top:20px; padding-right:20px; padding-bottom:20px; padding-left:20px;'>
<table width='370' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' width='170' style='padding-right:10px'><img src='"
. $webaddress . $logo . "' />
</td>
<td valign='top' width='190' style='font-family:Helvetica,Arial,Verdana,sans-serif; font-size:12px; color:#555;'>
<p style='margin-top:0; margin-bottom:0;'>
<span style='font-weight:bold;'>From:</span>" . $yourname . "<br>
<span style='font-weight:bold;'>Email:</span> <a style='text-decoration:none; color:#6927B2;' href='mailto:" . $youremail . "'>" . $youremail . "</a></p>
<p style='padding-top:200px;'>" . $message .
"</p>
<a href='" . $webaddress . "'><img src='http://recycledoc.com/emails/zoosh_tellafriend/visit.png' width='120' height='20' alt='Visit'></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
if (mail($friendsemail, $subject, $body, $headers)) {
echo "Thank you for telling your friend about my website. <a href='#' id='goback'>Click here</a> to tell another friend.";
} else {
echo "Sorry. There was a problem sending your email. Please try again!";
}
mail($adminemail, $subject, $body, $headers);
mail($youremail, $subject, $body, $headers);