Sorki :/
Kod PHP:
<?php
// CONFIG YOUR E-MAIL
define('SEND_TO', '[email protected]');
define('SUCCESS_MESSAGE', 'Dziękujemy {name}.');
define('INBOX_MESSAGE', 'Name: {name} {enter} Company: {company} {enter} E-mail: {email} {enter} Phone number: {phone} {enter} Comment: {comment} {enter}');
// CONFIG YOUR ERROR MESSAGES
define('ERROR_MESSAGE_NAME', '(Proszę uzupełnić pole)');
define('ERROR_MESSAGE_EMAIL', '(Proszę wpisać adres email)');
define('ERROR_MESSAGE_EMAIL_INVALID', '(Adres email jest niepoprawny)');
define('ERROR_MESSAGE_PHONE_INVALID', '(Nieprawidłowy numer)');
define('ERROR_MESSAGE_COMMENT', '(Proszę wpisać treść wiadomości)');
// DON'T TOUCH BEGIN
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
@session_set_cookie_params(0, '/');
@session_start();
if (ini_get('register_globals')) {
$globals = array('_SESSION');
foreach ($globals as $global) {
foreach ($GLOBALS[$global] as $key => $value) {
if ($value === @$GLOBALS[$key]) {
unset($GLOBALS[$key]);
}
}
}
}
@ini_set('magic_quotes_gpc', 'Off');
if (ini_get('magic_quotes_gpc')) {
function clean($data) {
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = clean($value);
}
} else {
$data = stripslashes($data);
}
return $data;
}
$_POST = clean($_POST);
}
function php_self(){
if(isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO'])> 0){
return substr($_SERVER['PHP_SELF'], 0, (strlen($_SERVER['PHP_SELF']) - @strlen($_SERVER['PATH_INFO'])));
}else{
return $_SERVER['PHP_SELF'];
}
}
$subjects = explode(',', SUBJECTS);
$error = FALSE;
$send = FALSE;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comment = $_POST['comment'];
$pfind = array(
'+',
'-',
' '
);
$phone_check = str_replace($pfind, '', $phone);
if(empty($name)){
$error_name = ERROR_MESSAGE_NAME;
$error = TRUE;
}
if(empty($email)){
$error_email = ERROR_MESSAGE_EMAIL;
$error = TRUE;
}elseif(!eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', $email)){
$error_email = ERROR_MESSAGE_EMAIL_INVALID;
$error = TRUE;
}
if(!empty($phone)){
if(!ctype_digit($phone_check)){
$error_phone = ERROR_MESSAGE_PHONE_INVALID;
$error = TRUE;
}
}
if(empty($comment)){
$error_comment = ERROR_MESSAGE_COMMENT;
$error = TRUE;
}
if(!$error) {
if(strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$ent = "\r\n";
}elseif(strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
$ent = "\r";
}else{
$ent = "\n";
}
$find = array(
'{name}',
'{company}',
'{email}',
'{phone}',
'{comment}',
'{enter}'
);
$replace = array(
'name' => $name,
'company' => $company,
'email' => $email,
'phone' => $phone,
'commment' => $comment,
'enter' => $ent
);
$comment = str_replace($find, $replace, INBOX_MESSAGE);
$boundary = '----=_NextPart_' . md5(rand());
$headers = 'From: ' . $name . '<' . $email . '>' . $ent;
$headers .= 'X-Mailer: PHP/' . phpversion() . $ent;
$headers .= 'MIME-Version: 1.0' . $ent;
$headers .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $ent . $ent;
$message = '--' . $boundary . $ent;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $ent;
$message .= 'Content-Transfer-Encoding: base64' . $ent . $ent;
$message .= chunk_split(base64_encode($comment));
ini_set('sendmail_from', $email);
mail(SEND_TO, $subject, strip_tags(html_entity_decode($message)), $headers);
$send = TRUE;
$success = str_replace($find, $replace, SUCCESS_MESSAGE);
}
}
// DON'T TOUCH END
?>
[ code ]
no i form : calosc jest w pliku kontakt.php
[ code ]
<div id="form">
<? if($error) { ?><div class="error"><h1>Nieprawidłowo wypełniony formularz.</h1></div><? } ?>
<form method="post" action="<?=php_self() ?>">
<label for="name"> Imię i Nazwisko
<? if(!empty($error_name)) { ?>
<span class="error_message"><?=$error_name ?></span>
<? }elseif(!empty($name)){ ?>
<img src="image/icon/accept.png" />
<? } ?>
</label>
<input name="name" type="text" id="name" size="30" <? if(!empty($name)){ ?> value="<?=$name ?>" <? } ?> class="text-input" />
<label for="company">Firma
<? if(!empty($error_company)) { ?>
<span class="error_message"><?=$error_company?></span>
<? }elseif(!empty($company)){ ?>
<img src="image/icon/accept.png" />
<? } ?>
</label>
<input name="company" type="text" id="company" size="30" <? if(!empty($company)){ ?> value="<?=$company ?>" <? } ?> class="text-input" />
<label for="email"><span class="required">*</span> Email
<? if(!empty($error_email)) { ?>
<span class="error_message"><?=$error_email ?></span>
<? } elseif(!empty($email)){ ?>
<img src="image/icon/accept.png" />
<? } ?>
</label>
<input name="email" type="text" id="email" size="30" <? if(!empty($email)){ ?> value="<?=$email ?>" <? } ?> class="text-input" />
<label for="phone"><span class="required">*</span>Numer telefonu
<? if(!empty($error_phone)) {?>
<span class="error_message"><?=$error_phone?></span>
<? }elseif(!empty($phone)){ ?>
<img src="image/icon/accept.png" />
<? } ?>
</label>
<input name="phone" type="text" id="phone" size="30" <? if(!empty($phone)){ ?> value="<?=$phone ?>"<? } ?> class="text-input" />
<label for="comment"><span class="required">*</span> Wiadomość
<? if(!empty($error_comment)) { ?>
<span class="error_message"><?=$error_comment ?></span>
<? }elseif(!empty($comment)){ ?>
<img src="image/icon/accept.png" />
<? } ?>
</label>
<textarea name="comment" id="comment" rows="8"><? if(!empty($comment)){ echo $comment; } ?>
</textarea>
<br />
<input type="submit" class="submit" value="Send" />
</form>
</div>
<? } ?>
</div>