function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
return (mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header));
}
// изпращането на съобщение става така:
mail_utf8($to, $subject, $message, $header);
PHP<!DOCTYPE html>
<html xmlns="#" lang="bg-BG">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Включи се в нашата игра!</title>
<link href="#" rel="stylesheet" type="text/css" media="screen" />
</head>
<body background="#">
<div id="contact">
<h1>Включи се в нашите игри!</h1>
<form action="contact.php" method="post">
<fieldset>
<label for="name">Имена:</label>
<input name="name" type="name" id="name" placeholder="Въведете вашите имена" />
<label for="email">Email:</label>
<input name="email" type="email" id="email" placeholder="Въведете вашият email" />
<label for="comments">Отзив за нас:</label>
<textarea id="comments" name="comments" placeholder="Напишете отзив за нас"></textarea>
<input name="submit" type="submit" value="Изпратете" />
</fieldset>
</form>
</div>
</body>
</html>
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "#";
$email_subject = "Your email subject line";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($name)."\n";
$email_message .= "Last Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
function checkEmail($mail){
if(preg_match("/^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]/", $mail)){
return FALSE;
}
list($Username, $Domain) = explode("@",$mail);
if(getmxrr($Domain, $MXHost)){
return TRUE;
}else{
if(@fsockopen($Domain, 25, $errno, $errstr, 30)){
return TRUE;
}else{
return FALSE;
}
}
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'From: '.$sitetitle.' <[email protected]>' . "\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
//$headers .='From:'.$from . "\r\n" . 'Reply-To:$from' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($email, "Успешна регистрация в $sitetitle", $mesage, $headers);
Много вероятно е този код да има проблеми с маймунски символи в някои пощи. Липсва =?UTF-8?B?.base64_encode на събжекта.Размишлявай си над другото, не мога да ти напиша всичко, но имаш материал.
PHP:function checkEmail($mail){ if(preg_match("/^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]/", $mail)){ return FALSE; } list($Username, $Domain) = explode("@",$mail); if(getmxrr($Domain, $MXHost)){ return TRUE; }else{ if(@fsockopen($Domain, 25, $errno, $errstr, 30)){ return TRUE; }else{ return FALSE; } } } $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n"; $headers .= 'From: '.$sitetitle.' <[email protected]>' . "\r\n"; $headers .= "X-Mailer: PHP/".phpversion(); //$headers .='From:'.$from . "\r\n" . 'Reply-To:$from' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email, "Успешна регистрация в $sitetitle", $mesage, $headers);
Много вероятно е този код да има проблеми с маймунски символи в някои пощи. Липсва =?UTF-8?B?.base64_encode на събжекта.
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n"
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:
Ама ти сериозно ли????
Има ли смисъл да се занимавам със теб???
Ти въобще си нямаш и на идея, а иначе голям смях. Ами смей се, нали за това си в форума, да се смееш, толкова си прост хейтър, че даже не искам да си цапам клавиатурата за да те обидя!!!
Аре бегай да учиш, че трудно си е php има много и функции и неща. Балък!!!
Сега разбрах защо сайтовете от "медията" ти изглеждат в стил 90-те, ми ти и си спрял с PHP-то някъде там.
Така е прав си!
Сега разбрах защо сайтовете от "медията" ти изглеждат в стил 90-те, ми ти и си спрял с PHP-то някъде там.
Пич, по-горе сме ти дали код, просто трябваше да си заместиш 4-5 реда. Пиша го без да го тествам, ти провери, дали всичко е ок:А бре пичоуе , все пак някой ще помогне ли с нещо истинско, качествено и работещо по всички нови стандарти или ще си се разправяте?
<?php
function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
return (mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header));
}
if (isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "#";
$email_subject = "Your email subject line";
function died($error)
{
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error . "<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
// $string_exp = "/^[A-Za-z .'-]+$/";
$string_exp = '/^[a-zA-Z .\p{Cyrillic}\'\-]+$/u';
if (!preg_match($string_exp, $name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if (!preg_match($string_exp, $name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if (strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if (strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array(
"content-type",
"bcc:",
"to:",
"cc:",
"href"
);
return str_replace($bad, "", $string);
}
$email_message .= "First Name: " . clean_string($name) . "\n";
$email_message .= "Last Name: " . clean_string($name) . "\n";
$email_message .= "Email: " . clean_string($email) . "\n";
$email_message .= "Comments: " . clean_string($comments) . "\n";
// create email headers
$headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'X-Mailer: PHP/' . phpversion();
// @mail($email_to, $email_subject, $email_message, $headers);
mail_utf8($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>