<?
include("config.php");
?>
<html>
<head>
<META NAME="Title" CONTENT="<? echo $title?>">
<title><? echo $title?></title>
<link rel="stylesheet" href="stylesheet.php" type="text/css">
</head>
<body>
<?
if(isset($submit))
{
function msg($messagetype,$m)
{
global $goback;
?>
<br>
<br>
<table width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><? echo $messagetype ?></td>
</tr>
<tr>
<td>
<?
echo "<li>".$m."</li><P>";
echo"<center><br><input type=\"button\" value=\"".$goback."\" onClick=\"history.go(-1)\"></center> ";
?>
</td>
</tr>
</table>
<p>
<?
exit;
}
// Checks the form submission
/*---------------------------------------------------------------------------------------*/
/* function checks the empty fields */
function check_fields($field,$fieldname,$errormessage)
{
if (empty ($field))
{
msg("$errormessage","$fieldname");
}
}
check_fields ("$sname","$yourname","$emptyfield");
/* Function checks the validity of the email addresses */
function check_email($email,$mailtype,$errmessage)
{
global $emptymail1,$emptymail2;
if (!empty($email))
{
$mail_test= trim($email);
// credit to the function creator
if (!eregi("^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$", $mail_test))
{
msg( "$errmessage","$mail_test");
}
}
else
{
msg( "$emptymail1","$mailtype");
}
}
check_email("$smail","$yourmail","$invalidmail");
check_email("$rmail","$recipientmail","$invalidmail");
/* building the mail body */
$mailbody=$message."\n";
if (empty($message))
{
$mailbody.="Check out this link:\n";
$mailbody.=$link;
}
$mailbody.="\n$bestwishes,\n$sname\n";
$mailbody.="\n-------------------------------------------------------\n";
$mailbody.=$author;
$mailheaders="From: $sname<$smail>\n"; // bug fix - thanks rahul!
/* building the body of the mail for the sender */
if ($mailtosender=="1")
{
$smailbody=$sname.",\n";
$smailbody.=$thankyoumessage."\n";
$smailbody.="\n-------------------------------------------------------\n";
$smailbody.=$author;
$smailheaders="From: $sitename<$adminmail>\n";
mail($smail,$thankyousubject,$smailbody,$smailheaders);
}
/* sends the mail */
if (@mail($rmail,$mailsubject,$mailbody,$mailheaders))
{
msg( "$mailsent","$rmail");
}
else
{
msg ("$error","$mailproblem");
}
}
?>
</body>
</html>