我有php表单的问题。收到的邮件没有正确显示重音字符,ščťžýáíé 等字符。
如果有人可以提供帮助,我将不胜感激:)
这是我的整个 php 页面:
<?php
$headers = 'Content-type: text/html; charset=UTF-8' . "\r\n" .
// Set email variables $email_to = 'office@victum.sk'; $email_subject = 'Form submission';
// Set required fields $required_fields = array('fullname','surname','firma','ulica','psc','obec','funkcia','ucet','ico','dic','icdph','telefon','email','comment');
// set error messages $error_messages = array( 'fullname' => 'Prosím zadajte krstné meno.', 'surname' => 'Prosím zadajte priezvisko.', 'firma' => 'Prosím zadajte názov firmy.', 'ulica' => 'Prosím zadajte ulicu.', 'psc' => 'Prosím zadajte PSČ.', 'obec' => 'Prosím zadajte obec.', 'funkcia' => 'Prosím zadajte funkciu vo firme.', 'ucet' => 'Prosím zadajte číslo účtu.', 'ico' => 'Prosím zadajte IČO.', 'dic' => 'Prosím zadajte DIČ.', 'icdph' => 'Prosím zadajte IČDPH.', 'telefon' => 'Prosím zadajte kontakt.', 'email' => 'Prosím zadajte správnu formu email adresy.', 'comment' => 'Prosím zadajte poznámku pre pokračovanie.' );
// Set form status $form_complete = FALSE;
// configure validation array $validation = array();
// check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$email_content = 'New Website Comment: ' . "\n\n";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($email_to, $email_subject, $email_content);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- Contact Form Designed by James Brand @ dreamweavertutorial.co.uk -->
<!-- Covered under creative commons license - http://dreamweavertutorial.co.uk/permissions/contact-form-permissions.htm -->
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../contact/css/contactform.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="contact/validation/validation.js"></script>
<script type="text/javascript">
var nameError = '<?php echo $error_messages['fullname']; ?>';
var emailError = '<?php echo $error_messages['email']; ?>';
var commentError = '<?php echo $error_messages['comment']; ?>';
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
</head>
<body onload="MM_preloadImages('contact/images/x.png')">
<div id="formWrap">
<h2 style="color:#9e0039; text-align:center;">HR Salón - Registračný Formulár</h2>
<div id="form">
<?php if($form_complete === FALSE): ?>
<form action="contact.php" method="post" id="comments_form">
<div class="row">
<div class="label">Meno</div> <!-- end. label -->
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" />
<?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Priezvisko</div> <!-- end. label -->
<div class="input">
<input type="text" id="surname" class="detail" name="surname" value="<?php echo isset($_POST['surname'])? $_POST['surname'] : ''; ?>" />
<?php if(in_array('surname', $validation)): ?><span class="error"><?php echo $error_messages['surname']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Názov Firmy</div> <!-- end. label -->
<div class="input">
<input type="text" id="firma" class="detail" name="firma" value="<?php echo isset($_POST['firma'])? $_POST['firma'] : ''; ?>" />
<?php if(in_array('firma', $validation)): ?><span class="error"><?php echo $error_messages['firma']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Ulica</div> <!-- end. label -->
<div class="input">
<input type="text" id="ulica" class="detail" name="ulica" value="<?php echo isset($_POST['ulica'])? $_POST['ulica'] : ''; ?>" />
<?php if(in_array('ulica', $validation)): ?><span class="error"><?php echo $error_messages['ulica']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">PSČ</div> <!-- end. label -->
<div class="input">
<input type="text" id="psc" class="detail" name="psc" value="<?php echo isset($_POST['psc'])? $_POST['psc'] : ''; ?>" />
<?php if(in_array('psc', $validation)): ?><span class="error"><?php echo $error_messages['psc']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Obec</div> <!-- end. label -->
<div class="input">
<input type="text" id="obec" class="detail" name="obec" value="<?php echo isset($_POST['obec'])? $_POST['obec'] : ''; ?>" />
<?php if(in_array('obec', $validation)): ?><span class="error"><?php echo $error_messages['obec']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Funkcia vo firme</div> <!-- end. label -->
<div class="input">
<input type="text" id="funkcia" class="detail" name="funkcia" value="<?php echo isset($_POST['funkcia'])? $_POST['funkcia'] : ''; ?>" />
<?php if(in_array('funkcia', $validation)): ?><span class="error"><?php echo $error_messages['funkcia']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Bankový účet/IBAN</div> <!-- end. label -->
<div class="input">
<input type="text" id="ucet" class="detail" name="ucet" value="<?php echo isset($_POST['ucet'])? $_POST['ucet'] : ''; ?>" />
<?php if(in_array('ucet', $validation)): ?><span class="error"><?php echo $error_messages['ucet']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">IČO</div> <!-- end. label -->
<div class="input">
<input type="text" id="ico" class="detail" name="ico" value="<?php echo isset($_POST['ico'])? $_POST['ico'] : ''; ?>" />
<?php if(in_array('ico', $validation)): ?><span class="error"><?php echo $error_messages['ico']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">DIČ</div> <!-- end. label -->
<div class="input">
<input type="text" id="dic" class="detail" name="dic" value="<?php echo isset($_POST['dic'])? $_POST['dic'] : ''; ?>" />
<?php if(in_array('dic', $validation)): ?><span class="error"><?php echo $error_messages['dic']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">IČ DPH</div> <!-- end. label -->
<div class="input">
<input type="text" id="icdph" class="detail" name="icdph" value="<?php echo isset($_POST['icdph'])? $_POST['icdph'] : ''; ?>" />
<?php if(in_array('icdph', $validation)): ?><span class="error"><?php echo $error_messages['icdph']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Telefón</div> <!-- end. label -->
<div class="input">
<input type="text" id="telefon" class="detail" name="telefon" value="<?php echo isset($_POST['telefon'])? $_POST['telefon'] : ''; ?>" />
<?php if(in_array('telefon', $validation)): ?><span class="error"><?php echo $error_messages['telefon']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Poplatok</div> <!-- end. label -->
<div class="input">
<p>
<label>
<input type="radio" name="Poplatok" value="140 EUR bez DPH" id="RadioGroup1_0" />
Základný poplatok - 140 EUR bez DPH</label>
<br />
<label>
<input type="radio" name="Poplatok" value="110 EUR bez DPH" id="RadioGroup1_1" />
Zľava pre klientov Intenzívy, Maxman Consultants, TCG, ZRRĽZ - 110 EUR bez DPH</label>
<br />
</p>
</div><!-- end .input -->
<div class="context"></div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Email</div> <!-- end. label -->
<div class="input">
<input type="text" id="email" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" />
<?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Všetky informácie, ktoré zadávate, podliehajú ochrane osobných údajov.</div> <!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Vaša správa</div> <!-- end. label -->
<div class="input2">
<textarea id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea>
<?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context"></div> <!-- end .context -->
</div><!-- end .row -->
<div class="submit">
<input type="submit" id="submit" name="submit" value="Odoslať" />
</div><!-- end .submit -->
</form>
<div id="box9">
<p style="text-align:center; padding-top:5px; font-size:18px; padding-bottom:15px;"><strong>Storno podmienky</strong></p>
<p style="text-align:center; padding-top:5px; font-size:16px; padding-bottom:15px;">Organizátor si vyhradzuje právo zrušiť akciu. V prípade jej zrušenia bude poplatok vrátený
klientovi v plnej výške. Klient môže zrušiť registráciu len písomne, najneskôr však do 18.10. 2013. Stornovací
poplatok je 20% zo zaregistrovanej ceny. Pri zrušení registrácie zo strany klienta po uvedenom termíne sa
poplatok nevracia. Namiesto prihláseného účastníka sa môže zúčastniť náhradník. </p>
</div>
<?php else: ?>
<p style="font-size:25px; font-family:Arial, Helvetica, sans-serif; color:#255E67; margin-left:25px;">Ďakujeme!</p>
<script type="text/javascript">
setTimeout('ourRedirect()',3000)
function ourRedirect(){
location.href='http://hrsalon.sk/partneri.html'
}
</script>
<?php endif; ?>
</div>
</div>
</body>
</html>