Created
April 10, 2014 18:56
-
-
Save anonymous/10411873 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/plain; charset=UTF-8'); | |
$config = array( | |
'emails' => ['[email protected]'], | |
'subject' => "Nowe zgloszenie Energia", | |
'fields' => array ( | |
'name' => array ('label' => 'Imię i nazwisko'), | |
'email' => array ('label' => 'Adres e-mail'), | |
'phone' => array ('label' => 'Telefon'), | |
'street' => array ('label' => 'Ulica'), | |
'city' => array ('label' => 'Miasto'), | |
'message' => array ('label' => 'Wiadomość', 'newline' => true), | |
), | |
); | |
$message = 'Nowe zgłoszenie' . "\n\n"; | |
$valid = true; | |
$mq = get_magic_quotes_gpc(); | |
foreach ($config['fields'] as $key => $field) { | |
if (empty($_POST[$key])) { | |
$valid = false; | |
break; | |
} | |
$value = $_POST[$key]; | |
if ($mq) { | |
$value = stripslashes($value); | |
} | |
$newline = isset($field['newline']) ? "\n" : ""; | |
$message .= sprintf("%s: %s%s\n", $field['label'], $newline, $value); | |
} | |
if ($valid) { | |
foreach ($config['emails'] as $recipient) { | |
mail($recipient, $config['subject'], $message, 'Content-type: text/plain; charset=UTF-8'); | |
} | |
} | |
$target = isset($_POST['target']) ? $_POST['target'] : null; | |
$target = ($mq && $target) ? stripslashes($target) : $target; | |
if ($target) { | |
header('Location: ' . $target . ((false === strpos($target, '?'))?'?':'&') . 'success=' . ((int)$valid)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment