I need to teach mailForm to use Russian charset=windows-1251
Here is the script
<?php
//----- Start Config -----\\
//enter the path to sendmail
$mail_path = "/usr/sbin/sendmail";
//Recipient should be selected from a list, true or false
$listofrecipients = "false";
//sub variable (only edit if above value is set to false)
//enter the email address you wish emails to be sent to
$mail_to = "****@*******.com";
//sub variable (only edit if above value is set to true)
//define list of recipients the user can chose from. Name & Email address should be seperated by ><
$recipientslist = array("Name 1 ><
name1@yourdomain.com", "Name 2 ><
name2@yourdomain.com", "Name 3 ><
name3@yourdomain.com");
//Subject should be selected from a list, true or false
$listofsubjects = "false";
//sub variable (only edit if above value is set to true)
//define list of subjects the user can chose from
$subjects = array("Info Request", "Members", "Feedback", "Webmaster", "Other");
//use security code feature, true or false
$usesecuritycode = "true";
//use time limit feature, true or false
$usetimelimit = "true";
//sub variable (only edit if above value is set to true)
//set time delay if using time limit feature
$delay = "30";
//redirect to another page after successful submission, true or false
$redirectonsuccess = "false";
//sub variable (only edit if above value is set to true)
//set address of page to redirect to after successful submission, can be relative
$redirecturl = "http://www.oldfashionbluesproject.com/";
//allow user to get a copy of the message sent to them, true or false
$copyme = "false";
//store submissions in a database, true or false
$store = "false";
//sub variables (only edit if above value is set to true
//MySQL Host
$host = "localhost";
//MySQL User
$user = "user";
//MySQL Pass
$pass = "pass";
//MySQL Database Name
$dbname = "database";
//Table Name
$tablename = "ContactFormLog";
//Date Format, see
http://www.php.net/date
$dateformat = "d/m/Y H:i:s";
//user has to preview before can submit, true or false
$preview = "true";
//remember user's name and e-mail, true or false
$rememberdetails = "false";
//sub variables (only edit if above value is set to true
//Days to remember details for
$rememberdays = "7";
//----- End Config -----\\
//----- Start Set PHP Variables -----\\
ini_set("sendmail_path", $mail_path);
ini_set("magic_quotes_gpc", 1);
//----- End Set PHP Variables -----\\
//----- Start Functions -----\\
//function to check email format
function check_email($str)
{
if(ereg("^.+@.+\\..+$", $str))
return 1;
else
return 0;
}
//function to get submitted values
function get_values($slashes,$decode)
{
global $userName;
global $userEmail;
global $userSubject;
global $userMessage;
global $userCopyMe;
global $userEmailTo;
global $rememberdetails;
$userName = htmlentities(strip_tags($_POST['userName']));
$userEmail = htmlentities(strip_tags($_POST['userEmail']));
$userSubject = htmlentities(strip_tags($_POST['userSubject']));
$userMessage = htmlentities(strip_tags($_POST['userMessage']));
$userCopyMe = htmlentities(strip_tags($_POST['userCopyMe']));
$userEmailTo = htmlentities(strip_tags($_POST['userEmailTo']));
if ($slashes == "1") {
$userName = stripslashes($userName);
$userEmail = stripslashes($userEmail);
$userSubject = stripslashes($userSubject);
$userMessage = stripslashes($userMessage);
$userCopyMe = stripslashes($userCopyMe);
$userEmailTo = stripslashes($userEmailTo);
}
if ($decode == "1") {
$userName = html_entity_decode($userName);
$userEmail = html_entity_decode($userEmail);
$userSubject = html_entity_decode($userSubject);
$userMessage = html_entity_decode($userMessage);
$userCopyMe = html_entity_decode($userCopyMe);
$userEmailTo = html_entity_decode($userEmailTo);
}
}
//function to clear submitted values
function clear_values()
{
global $userName;
global $userEmail;
global $userSubject;
global $userMessage;
global $userCopyMe;
global $userEmailTo;
global $rememberdetails;
if ($rememberdetails != "true") {
$userName = "";
$userEmail = "";
}
$userSubject = "";
$userMessage = "";
$userCopyMe = "";
$userEmailTo = "";
}
//function to display message
function display_messages()
{
global $message;
global $messagenoterror;
$y = "0";
if (!empty($message) && $messagenoterror != "1") {
echo "The following errors were encountered when trying to process
your message:<br />";
}
while ($y < 10) {
if (!empty($message[$y])) {
if ($messagenoterror != "1") {
echo " - ";
}
echo $message[$y]."<br />";
}
$y++;
}
}
//----- End Functions -----\\
//----- Start Set Variables -----\\
$mail_subject = $_POST['userSubject'];
$submittime = $_SESSION['submittime'];
$currenttime = time();
$allowedtime = $currenttime - $delay;
$timeleft = $submittime - $allowedtime;
$p = "0";
get_values(1,1);
$EmailContent = "Name : ".$userName."\n"."Email : ".$userEmail."\n"."Subject : ".$userSubject."\n"."Message : \n".$userMessage."\n\n"."User IP : ".$_SERVER["REMOTE_ADDR"];
//----- End Set Variables -----\\
//check if form submitted
if ($_POST){
//----- Start Error Checking -----\\
//check to see if fields already been checked
if ($_POST['previewdone'] != "1") {
//check if all fields filled in
if (!$_POST['userName'] || !$_POST['userEmail'] || !$_POST['userSubject'] || !$_POST['userMessage']){
$message[$p] = "All required fields not filled in.";
$p++;
get_values(1,0);
$notcomplete = "1";
}
//check if email is in valid format
if(check_email($_POST['userEmail']) == "0" && $_POST['userEmail']){
$message[$p] = "Invalid e-mail address.";
$p++;
get_values(1,0);
}
//check if security code is correct
if($_POST['userSecurityCode'] != base64_decode($_POST['SecurityCode']) && $usesecuritycode == "true" && $notcomplete != "1"){
$message[$p] = "Wrong security code";
$p++;
get_values(1,0);
}
//check that x seconds has passed
if($submittime > $allowedtime && $usetimelimit == "true"){
$message[$p] = "You are trying to send messages too often, please try again after ".$timeleft." seconds";
$p++;
get_values(1,0);
}
}
//----- End Error Checking -----\\
//----- Start Set Cookies ------\\
if ($rememberdetails == "true") {
$cookietime = time()+60*60*24*$rememberdays;
//set cookie to remember userid for x days
setcookie("userName", $_POST['userName'], $cookietime, "/");
//set cookie to remember password for x days
setcookie("userEmail", $_POST['userEmail'], $cookietime, "/");
}
//----- End Set Cookies ------\\
//----- Start Final Check & Process Form ------\\
if ($preview == "true" && $_POST['previewdone'] == "1") {
$continue = "1";
} elseif ($preview == "true" && $_POST['previewdone'] != "1") {
$continue = "0";
} else {
$continue = "1";
}
//check to see whether there are any errors, if no then continue
if (empty($message) && $continue == "1" && empty($_POST['edit'])){
//check to see whether the user can pick the recipitent, if yes get recepitent chosen
if ($listofrecipients == "true") {
$explodedresult = explode(" >< ", $recipientslist[$_POST['userEmailTo']]);
$mail_to = $explodedresult[1];
}
//Check to see if mail sent correctly
get_values(1,0);
if(mail($mail_to,$mail_subject,$EmailContent,"From :".$userName." <".$userEmail.">")){
//check to see if user wants a copy of the message, if yes send them one
if ($_POST['userCopyMe'] == "1"){
mail($_POST['userEmail'],"Copy of sent message: ".$mail_subject,$EmailContent,"From:".$userNam e." <".$userEmail.">");
}
//check to see if user wants to store submissions
if ($store == "true") {
//connect to db
$connect = @mysql_connect($host,$user,$pass);
//select db
$selectdb = @mysql_select_db($dbname);
//get variables
get_values(1,1);
$userAgent = $_SERVER["HTTP_USER_AGENT"];
$userIP = $_SERVER["REMOTE_ADDR"];
$userTime = date($dateformat);
//insert data
$sql = "INSERT INTO `$tablename` (`ID`, `userName`, `userEmail`, `userSubject`, `userMessage`, `userCopyMe`, `userEmailTo`, `userAgent`, `userIP`, `userTime`) VALUES ('', '$userName', '$userEmail', '$userSubject', '$userMessage', '$userCopyMe', '$userEmailTo', '$userAgent', '$userIP', '$userTime')";
$result = @mysql_query($sql);
}
//tell user message sent successfully
$message[0] = "Thank you, your message has been sent.";
$messagenoterror = "1";
//clear form values
clear_values();
//store submit time for use with time limit feature
$_SESSION['submittime'] = time();
//check to see if user should be redirected
if ($redirectonsuccess == "true") {
?>
<script type="text/javascript">
<!--
window.location.href = "<?php echo $redirecturl; ?>";
-->
</script>
<?php
}
//if error provide link
}else{
//provide link to user to send using their default email
$message[0] = "There was an error. Please click <a href=\"mailto:".$mail_to."?subject=".$_POST['userSubject']."&body=".$_POST['userMessage']."\">here</a> to send your message via your default e-mail program.";
$messagenoterror = "1";
get_values(1,0);
}
$formsent = "1";
}
} else {
if ($rememberdetails == "true") {
$userName = $_COOKIE['userName'];
$userEmail = $_COOKIE['userEmail'];
}
}
//----- End Final Check & Process Form ------\\
?> <!-- Start Output --> <?php
if ($preview == "true" && $_POST['previewfirst'] == "1" && $formsent != "1" && empty($message) && empty($_POST['edit'])) {
get_values(1,0);
?> <!-- Start Preview -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100" class="table-text">
<tr align="CENTER" valign="top" class="table-text">
<td>
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#8E2424" style="border-collapse: collapse" class="table-text">
<tr bgcolor="#8E2424">
<td height="12" colspan="2"></td>
</tr>
<tr>
<td height="25" width="174">Names : </td>
<td height="25" width="420"><?php echo $userName; ?>
<input type="hidden" name="userName" value="<?php echo $userName; ?>" />
</td>
</tr>
<tr>
<td height="25" width="174">Email : </td>
<td height="25" width="420"><?php echo $userEmail; ?>
<input type="hidden" name="userEmail" value="<?php echo $userEmail; ?>" />
</td>
</tr>
<tr>
<td height="25" width="174">Subject : </td>
<td height="25" width="420"><?php if ($listofsubjects == "true") { ?>
<?php echo $userSubject; ?> <?php } else { ?>
<?php
$i = "0";
while ($i < count($subjects)){
?> <?php if ($userSubject == $subjects[$i]) { echo $subjects[$i]; } ?> <?php $i++; }?>
<?php } ?>
<input type="hidden" name="userSubject" value="<?php echo $userSubject; ?>" />
</td>
</tr>
<tr>
<td height="25" colspan="2">Message : <br />
<?php echo nl2br($userMessage); ?>
<input type="hidden" name="userMessage" value="<?php echo $userMessage; ?>" />
</td>
</tr>
<tr align="center" bgcolor="#8E2424">
<td height="25" colspan="2">
<input type="submit" name="edit" value="Edit" />
<input type="submit" name="submit" value="Send" />
</td>
</tr>
</table>
<!-- Start Preview Done Field -->
<input type="hidden" name="previewdone" value="1" />
<!-- End Preview Done Field -->
</form>
</td>
</tr>
</table>
<!----- End Preview -----> <br />
<?php
} else {
?> <?php
//display any messages
display_messages();
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100" class="warning">
<tr align="CENTER" valign="top">
<td>
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#8E2424" style="border-collapse: collapse" class="table-text">
<tr>
<td height="12" colspan="2" bgcolor="#8E2424"> Please
use English</td>
</tr>
<tr>
<td height="25" width="23%"> <!-- Start Name Field-->
Name : </td>
<td height="25" width="77%">
<input type="text" name="userName" maxlength="30" size="40" style='border: 1 solid rgb(50,50,50);' value="<?php echo $userName; ?>" />
<!-- End Name Field--></td>
</tr>
<tr>
<td height="25" width="23%"> <!-- Start E-mail Field-->
E-mail : </td>
<td height="25" width="77%">
<input type="text" name="userEmail" maxlength="30" size="40" style='border: 1 solid rgb(50,50,50);' value="<?php echo $userEmail; ?>" />
<!-- End E-mail Field--></td>
</tr>
<tr>
<td height="25" width="23%"> <!-- Start Subject Field-->
Subject : </td>
<td height="25" width="77%"><?php if ($listofsubjects == "true") { ?>
<input type="text" name="userSubject" value="<?php echo $userSubject; ?>" />
<?php } else { ?>
<select name="userSubject">
<?php
$i = "0";
while ($i < count($subjects)){
?>
<option value="<?php echo $subjects[$i]; ?>" <?php if ($userSubject == $subjects[$i]) { echo "selected=\"selected\""; }?>><?php echo $subjects[$i]; ?></option>
<?php $i++; }?>
</select>
<?php } ?> <!-- End Subject Field--></td>
</tr>
<tr align="left">
<td height="25" colspan="2"> <b><font size="1" face="Verdana" />Message
:</font></b> <br />
<textarea name="userMessage" rows="8" cols="50" style='border: 1 solid rgb(50,50,50); background-color: #CE791C;'><?php echo $userMessage; ?></textarea>
<!-- End Message Field--></td>
</tr>
<tr>
<td height="25" colspan="2"> <!-- Start Security Code Field-->
<?php
//check to see if security code feature is on
if ($usesecuritycode == "true") {
$randcode = mt_rand(100000, 999999);
$randcodesec = base64_encode($randcode);
?> <b><font size="1" face="Verdana"> Type the code you see
on the image below </font></b><br />
<input type="text" name="userSecurityCode" maxlength="6" size="8" style='border: 1 solid rgb(50,50,50);'>
<input type="hidden" name="SecurityCode" value="<?php echo $randcodesec; ?>" />
<br />
<img src="gd.php?randcode=<?php echo $randcodesec; ?>" alt="Security Code" />
<?php } ?> <!-- End Security Code Field--></td>
</tr>
<tr align="center">
<td height="25" colspan="2" bgcolor="#8E2424"><!-- Start Submit Button-->
<input type="submit" name="submit" value="<?php if ($preview == "true") { echo "Preview Before Send"; } else { echo "Send"; } ?>" />
<!-- End Submit Button--></td>
</tr>
<!-- Start Preview First Field --> <?php if ($preview == "true") {?>
<input type="hidden" name="previewfirst" value="1" />
<?php } ?> <!-- End Preview First Field -->
</table>
</form>
</td>
</tr>
</table>
<br />
<?php
}
ob_end_flush();
?> <!-- End Output -->
fastreplies