Witam,
jestem totalnym laikiem i nie potrafię znaleźć błędu w tym formularzu
byłby ktoś skłonny rzucić na to okiem?
(sprawdzałem serwer na innym skrypcie tego typu (html + php) i PHP działa prawidłowo)
Dziękuję i pozdrawiam:
4teista
[html][/html]
</div>
<div class="col-md-6 sep-top-xs wow bounceInRight" data-wow-delay="0.9s">
<div class="contact-form">
<div id="successMessage" style="display:none" class="alert alert-success text-center">
<p><i class="fa fa-check-circle fa-2x"></i></p>
<p>Dziękuję za wysłanie wiadomości! Postaram się odpisać jak najszybciej.</p>
</div>
<div id="failureMessage" style="display:none" class="alert alert-danger text-center">
<p><i class="fa fa-times-circle fa-2x"></i></p>
<p>Wystąpił problem podczas wysyłania wiadomości. Spróbuj ponownie.</p>
</div>
<div id="incompleteMessage" style="display:none" class="alert alert-warning text-center">
<p><i class="fa fa-exclamation-triangle fa-2x"></i></p>
<p>Wypełnij wszystkie pola formularza przed wysłaniem wiadomości.</p>
</div>
<form id="contactForm" action="php/contact.php" method="post" class="validate">
<div class="form-group sep-top-xs">
<label for="contactFormName" class="upper">Imię i Nazwisko</label>
<input id="contactFormName" type="text" placeholder="Wpisz imię i nazwisko" name="name" class="form-control input-lg required">
</div>
<div class="form-group sep-top-xs">
<label for="contactFormPhone" class="upper">Telefon</label>
<input id="contactFormPhone" type="text" placeholder="Wpisz numer telefonu" name="phone" class="form-control input-lg required">
</div>
<div class="form-group sep-top-xs">
<label for="contactFormEmail" class="upper">Email</label>
<input id="contactFormEmail" type="email" placeholder="Wpisz swój email" name="email" class="form-control input-lg required email">
</div>
<div class="form-group sep-top-xs">
<label for="contactFormComment" class="upper">Twoje pytanie</label>
<textarea id="contactFormComment" placeholder="Wpisz swoje pytanie" rows="9" name="comment" class="form-control input-lg required"></textarea>
</div>
<div class="form-group sep-top-xs">
<button type="submit" data-wow-delay="1.1s" class="btn btn-primary btn-lg wow bounceInRight"><i class="fa fa-paper-plane"></i> Wyślij wiadomość</button>
</div>
<!--input#subject.form-control.input-lg.required(type='text', placeholder='Subject of your message', name='subject')
-->
</form>
<div class="hidden"></div>
</div>
</div>
</div>
</div>
</section>
[php][/php]
<?php
header('Access-Control-Allow-Headers: x-requested-with');
header('Access-Control-Allow-Origin: *');
// Define constants. Put your desired values here.
define( 'RECIPIENT_NAME', '4teista' );
define( 'RECIPIENT_EMAIL', '4teista@domena.pl' );
define( 'EMAIL_SUBJECT', 'Wiadomość ze strony www.domena.pl' );
// Read and sanitize the form values
$status = false;
//$xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
$xhr = isset( $_POST['ajax'] )
? true
: false;
$senderName = isset( $_POST['senderName'] )
? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", '', $_POST['senderName'] )
: '';
$senderEmail = isset( $_POST['senderEmail'] )
? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", '', $_POST['senderEmail'] )
: '';
$subject = isset( $_POST['subject'] )
? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", '', $_POST['subject'] )
: EMAIL_SUBJECT;
$comment = isset( $_POST['comment'] )
? nl2br(strip_tags($_POST['comment']))
: '';
$phone = isset( $_POST['phone'] )
? strip_tags($_POST['phone'])
: '';
$company = isset( $_POST['company'] )
? strip_tags($_POST['company'])
: '';
// message body. Modify as needed.
$message_body = <<<ENDOFMESSAGE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<title>{$subject}</title>
</head>
<body>
<h3>{$subject}</h3>
<p>A new message has been sent from your Ottavio website:</p>
<table>
<tr>
<th>Name:</th>
<td>{$senderName}</td>
</tr>
<tr>
<th>Email:</th>
<td>{$senderEmail}</td>
</tr>
<tr>
<th>Phone:</th>
<td>{$phone}</td>
</tr>
<tr>
<th>Company:</th>
<td>{$company}</td>
</tr>
<tr>
<th>Message:</th>
<td>{$comment}</td>
</tr>
</table>
</body>
</html>
ENDOFMESSAGE;
// check the mandatory values: if they exist, send the email
if ( $senderName && $senderEmail && $comment ) :
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
// Set the required headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-UTF-8' . "\r\n";
$headers .= 'From: ' . $senderName . ' <' . $senderEmail . '>' ."\r\n";
$headers .= 'Reply-To: ' . $senderName . ' <' . $senderEmail . '>' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
// If needed, add CC and/or BCC recipients
//$headers .= 'Cc: mail1@example.com' . "\r\n";
//$headers .= 'Bcc: mail2@example.com' . "\r\n";
try {
mail( $recipient, $subject, $message_body, $headers );
$status = 'success';
} catch (Exception $e) {
$status = $e->getMessage();
}
else:
$status = 'error: incomplete data';
endif;
// Return an appropriate response to the browser
if ( $xhr ) :
// AJAX Request
echo $status;
else :
// HTTP Request ?>
<!doctype html>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<p>
<?php
if ( $status == 'success') :
echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>";
else :
echo "<p>There was a problem sending your message. Please try again.</p>";
endif;
?>
</p>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
endif; ?>