When someone enters foreign characters (like Cyrillic text, and Japanese/Chinese probably gives the same problem) into the mail form, the email that arrives is all gibberish.
For example this should read "test message from *name*" in Russian.
âõÑÂтþòþõ ÑÂþþñщõýøõ þт Úþрøý
I tried changing the header content-type thing from plain text to HTML but that didn't fix it.
The script I'm using is one I found online for free (eternal thanks to its author some of the lines are in Dutch)
Does anyone know how to let the form accept foreign characters? Thanks a lot in advance !!
<?
$your_email_address="theemail@whereitissentto.com";
if(empty($_GET) && empty($_POST)) {
die('Ongeldige actie');
}
// Emular register_globals on
if (!ini_get('register_globals')) {
$superglobales = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
array_unshift($superglobales, $_SESSION);
}
foreach ($superglobales as $superglobal) {
extract($superglobal, EXTR_SKIP);
}
}
// to prevent header injection
if (eregi("r",$_POST['your_email_address']) || eregi("n",$_POST['your_email_address'])){
exit;
}
// kick anyone whoever tried to inject a header in the form
foreach( $_POST as $value ){
if( strpos($value,'Content-Type:') !== FALSE ){
exit;
}
}
$fields = array_keys($_POST);
function headfunction($url) {
header ("Location: $url");
}
// protect the variable $reserved_vars
if(isset($reserved_vars)) {
unset($reserved_vars);
}
$reserved_vars = array("css_file", "background_color", "background_image", "text_color", "link_color", "visited_link_color", "active_link_color", "font_name", "font_size", "highlight_color", "required_fields", "after_url", "check_email_address", "subject", "your_email_address", "env_report", "owner_name", "autoresponse", "response_subject", "response_mail", "dodosmail_header_file", "dodosmail_footer_file");
function include_dodosmail_header($dodosmail_header_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_header_file)) {
include_once($dodosmail_header_file);
return;
} else {
echo "<html>n";
echo "<head>n";
echo "<title>n";
echo "DodosMailn";
echo "</title>n";
if($css_file != "")
echo "<link rel="stylesheet" type="text/css" href="$css_file">n";
echo "</head>n";
echo "<body bgcolor="$background_color" background="$background_image" text="$text_color" link="$link_color" vlink="$visited_link_color" alink="$active_link_color">n";
echo "<font face="$font_name" size="$font_size">n";
}
}
function include_dodosmail_footer($dodosmail_footer_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_footer_file)) {
include_once($dodosmail_footer_file);
return;
} else {
echo "</font>n</body>n</html>";
}
}
function dodosmail_error_handle($msg) {
global $highlight_color;
if(isset($highlight_color)) {
$extra_begin = "<font color="".$highlight_color."">";
$extra_end = "</font>";
} else {
$extra_begin = "<span class="DodosMailErrorHighLight">";
$extra_end = "</span>";
}
return $extra_begin.$msg.$extra_end;
}
// checking required fields
// in case they used comma and space, replace
if(strstr($required_fields, ", ")) {
$required_fields = str_replace(", ", ",", $required_fields);
} else {
$required_fields = $required_fields;
}
$required_fields = explode(",", $required_fields);
for($i = 0; $i < count($required_fields); $i++) {
$required_var_name = $required_fields[$i];
if(empty($$required_var_name)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class="DodosMailError">Fout! - het verplichte veld ".dodosmail_error_handle($required_var_name)." is niet ingevuld.n";
echo "<br /><br /><a href="javascript:history.back(1)">Terug</a>n";
echo "</p>n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
if($check_email_address == "yes" && !empty($email)) {
if(!check_email($email)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class="DodosMailError">Fout - het adres ".dodosmail_error_handle($email)." is niet geldig.n";
echo "<br /><br /><a href="javascript:history.back(1)">Terug</a>n";
echo "</p>n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars)) {
$inside_mail = $inside_mail;
} else {
if(is_array($$actual_var)) {
$inside_mail.= "$actual_var: ";
foreach($$actual_var as $actual_val) {
$inside_mail.= "$actual_val ";
}
$inside_mail.= "n";
} else {
$actual_val = stripslashes($$actual_var);
$inside_mail.= "$actual_var: $actual_valn";
}
}
}
// getting other information from the form
$cname = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$inside_mail.=
"
-----------------------------------------------------------------------
SENDER INFO:
IP: $_SERVER[REMOTE_ADDR]
Computer Name: $cname
Browser Type: $_SERVER[HTTP_USER_AGENT]
Page Referer: $_SERVER[HTTP_REFERER]
-----------------------------------------------------------------------
";
$headers .= "MIME-Version: 1.0rn";
$headers .= "X-Priority: 3rn";
$headers .= "X-MSMail-Priority: Normalrn";
$headers .= "X-Mailer: DodosMail 2.0 http://regretless.com/scripts/rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
//$headers .= "Date: ".date("R")."rn";
$headers .= "From: $name <$email>rn";
$success = mail($your_email_address, $subject, $inside_mail, $headers);
if($success) {
if($autoresponse == "yes") {
$response_subject = stripslashes($response_subject);
$response_mail = stripslashes($response_mail);
mail($email, $response_subject, $response_mail, "From: $owner_name <$your_email_address>");
}
if($after_url == "") {
// out put send info
include_dodosmail_header($dodosmail_header_file);
echo "<p>n";
echo "Het formulier is verzonden!</p><ul>";
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars))
echo "";
else {
if(is_array($$actual_var)) {
echo "<li>$actual_var: ";
foreach($$actual_var as $actual_val) {
echo "$actual_val ";
}
echo "</li>n";
} else {
$actual_val = stripslashes($$actual_var);
echo "<li>$actual_var: $actual_val</li>n";
}
}
}
echo "</ul>n<p></p>";
include_dodosmail_footer($dodosmail_footer_file);
exit;
} else {
headfunction($after_url);
}
} else {
include_dodosmail_header($dodosmail_header_file);
echo "<p class="DodosMailError">Fout - Het formulier is tijdelijk niet bruikbaar, gebruik ".dodosmail_error_handle($your_email_address)." om contact op te nemen.n";
echo "<br /><br /><a href="javascript:history.back(1)">Terug</a>n";
echo "</p>n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
function check_email($email) {
if( (preg_match('/(@.*@)|(..)|(@.)|(.@)|(^.)/', $email)) ||
(preg_match('/^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$/',$email)) ) {
return true;
}
return false;
}
?>
convert PHP array to Javascript array
I have a page that gets a request sent from AJAX, and I am trying to convert a PHP array to a javascript array. is this possible? I tried with Json_encode but it doesn't seem to work. is there
Match stored value with the current value in a loop
Hello,I have a MySQL db were I store articles in.I have a form to fill these articles, and in that form I can select images who are stored into a directory. Selecting the images works good but the
Auto-populating dropdowns and multiple forms.
Here's what I have so far:First drop down = select a state (works)This populates the second drop down (works)Second drop down = select a city (works)This populates the third drop down with local
Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.Some code runs as perfectly valid code, where i would like PHP to issue a warning / error.I guess this is because of the loose typing of PHP,
please hep to get values from a table row
can anyone tel me how I can select and get data from one row by pressing an Edit button in that row?<?phpif (!empty($avil_holidays)){ foreach ($avil_holidays as $val) { switch
contact form - output to page and email
I have the following in my controller:$message['name'] = htmlentities(strip_tags(trim($_POST['name']))); $message['email'] = htmlentities(strip_tags(trim($_POST['email'])));$to =
Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.a)create an html page to enter a row number (1-6) in a textbox to choose a list of student records.b)
How to have a log of all the status a VIM document had been ?
Hi guys,
Different actions for different parts of a string
<?phpfunction dosomething($string, $else = '') { if (empty($else)) $string = "<b>$string</b>"; else $string =
=> and <=
So I was digging through some code when I came across the <= operator. This is the first time I've ever seen it. I felt the same way I did when I first saw a ternary statement. What is