Witam,
Stworzyłem na bazie podanych tutoriali w sieci formularz, z którym mam problem, dokładniej z jego wysyłką.
Wstawiam wszystko co mam zrobione. Nie wiem jak użyć funkcji echo, dlatego mam wysyłkę do wszystkich foreach. Byłbym wdzięczny, także za pomoc w tym.
<form id="formElem" name="formElem" action="#" method="post"> <input id="name" name="name" type="text" AUTOCOMPLETE=OFF /> <input id="adres" name="adres" type="text" AUTOCOMPLETE=OFF /> <input id="telefon" name="telefon" type="text" AUTOCOMPLETE=OFF /> <input id="email" name="email" type="text" AUTOCOMPLETE=OFF /> <select id="typrejsu" name="typrejsu"> <label for="liczbamiejsc">Liczba rezerwowanych miejsc
</label> <select id="liczbamiejsc" name="liczbamiejsc"> <label for="ubezpieczenie">Dodatkowe ubezpieczenie
</label> <select id="ubezpieczenie" name="ubezpieczenie"> <select id="platnosc" name="platnosc"> <select id="waluta" name="waluta" AUTOCOMPLETE=OFF> <label for="platnik">Imię i nazwisko Płatnika
</label> <input id="platnik" name="platnik" AUTOCOMPLETE=OFF /> <input id="pesel" name="pesel" AUTOCOMPLETE=OFF /> xxxxxxxxxx
<label for="zaliczka">Potwierdzam wpłatę zaliczki
</label> <select id="zaliczka" name="zaliczka"> xxxxxxxxx
<input type="hidden" value="xyz@xyz.pl" name="to" id="to" /> <input type="hidden" value="Rezerwacja" name="subject" id="subject" /> <input type="hidden" value="rezerwacja.php" /> <button id="registerButton" type="button" name="submit" id="submit">Rezerwuj
</button>
<?php
$subject = $_POST['subject'];
$name = explode(',', $_POST['name'] ); $adres = explode(',', $_POST['adres'] ); $telefon = explode(',', $_POST['telefon'] ); $typrejsu = explode(',', $_POST['typrejsu'] ); $liczbamiejsc = explode(',', $_POST['liczbamiejsc'] ); $ubezpieczenie = explode(',', $_POST['ubezpieczenie'] ); $platnosc = explode(',', $_POST['platnosc'] ); $waluta = explode(',', $_POST['waluta'] ); $platnik = explode(',', $_POST['platnik'] ); $pesel = explode(',', $_POST['pesel'] ); $zaliczka = explode(',', $_POST['zaliczka'] ); $from = $_POST['email'];
$msg = "<b>Imię i nazwisko:</b> " .$_POST['name'] ."<br>\n";
$msg .= "<br>\n";
$msg .= "<b>Adres email:</b> " .$_POST['email'] ."<br>\n";
$msg .= "<b>Typ rejsu:</b> " .$_POST['typrejsu'] ."<br>\n";
$msg .= "<b>Dane płatnika:</b> " .$_POST['platnik'] ."<br>\n";
$msg .= "<b>Potwierdzenie wpłaty zaliczki:</b> " .$_POST['zaliczka'] ."<br>\n";
$msg .= "<b>Waluta:</b> " .$_POST['waluta'] ."<br>\n";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
foreach($to as $mail){
mail($mail, $subject, $msg, $headers); }
?>
Demo można zobaczyć tutaj:
LinkZ góry dziękuję za pomoc i życzę Szczęśliwego Nowego Roku (IMG:
style_emoticons/default/czarodziej.gif)
Wrzucam jeszcze JS , bo wiadomość była za długa.
$(FUNCTION() {
var fieldsetCount = $('#formElem').children().length;
var current = 1;
var stepsWidth = 0;
var widths = new Array();
$('#steps .step').each(FUNCTION(i){
var $step = $(this);
widths[i] = stepsWidth;
stepsWidth += $step.width();
});
$('#steps').width(stepsWidth);
$('#formElem').children(':first').find(':input:first').focus();
$('#navigation').SHOW();
$('#navigation a').bind('click',FUNCTION(e){
var $this = $(this);
var prev = current;
$this.closest('ul').find('li').removeClass('selected');
$this.parent().addClass('selected');
current = $this.parent().INDEX() + 1;
$('#steps').stop().animate({
marginLeft: '-' + widths[current-1] + 'px'
},500,FUNCTION(){
IF(current == fieldsetCount)
validateSteps();
else
validateStep(prev);
$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
});
e.preventDefault();
});
$('#formElem > fieldset').each(FUNCTION(){
var $fieldset = $(this);
$fieldset.children(':last').find(':input').keydown(FUNCTION(e){
IF (e.which == 9){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
$(this).blur();
e.preventDefault();
}
});
});
FUNCTION validateSteps(){
var FormErrors = false;
FOR(var i = 1; i < fieldsetCount; ++i){
var error = validateStep(i);
IF(error == -1)
FormErrors = true;
}
$('#formElem').DATA('errors',FormErrors);
}
FUNCTION validateStep(step){
IF(step == fieldsetCount) RETURN;
var error = 1;
var hasError = false;
$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(FUNCTION(){
var $this = $(this);
var valueLength = jQuery.trim($this.val()).length;
IF(valueLength == ''){
hasError = true;
$this.css('background-color','#FFEDEF');
}
else
$this.css('background-color','#FFFFFF');
});
var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
$link.parent().find('.error,.checked').remove();
var valclass = 'checked';
IF(hasError){
error = -1;
valclass = 'error';
}
$('<span class="'+valclass+'"></span>').insertAfter($link);
RETURN error;
}
$('#registerButton').bind('click',FUNCTION(){
IF($('#formElem').DATA('errors')){
alert('Prosimy poprawić dane w formularzu !');
RETURN false;
}
});
});