I'm working on a site where you have a form that can add multiple persons, you start with one person to subscribe and can add more if you like.
I have written a PHP document that's made for 1 person, but I like it to change if I use multiple persons.
Is it possible to change my mail.php
with the use of some jQuery code?
SCRIPT
var x = 0;
$('#addPlayer').on('click', function() {
x++;
});
if(x > 0) {
for(i = x; i>=0; i--) {
// add extra persoon to mail.php
}
}
else {
mail.php
}
if (i == 0) {
use new mail.php
}
For every time a new player has been added (click on button) their is a count.
mail.php
<?php
$to = "example@mail.com";
$from = $_POST['email'];
$name = $_POST['name'];
$voornaam = $_POST['first_name'];
$geboortedatum = $_POST['date'];
$telefoon = $_POST['phone_number'];
$type = $_POST['r0'];
$adres = $_POST['address'];
$postcode = $_POST['postcode'];
$huisnr = $_POST['number'];
$gemeente = $_POST['municipality'];
$prijs = $_POST['price'];
//getting the new inputs for a new player
//extra persoon
$naam1 = $_POST['spname1'];
$voornaam1 =$_POST['Firstname1'];
$mail1 = $_POST['spemail1'];
$geboortedatum1 = $_POST['datepicker1'];
$telefoon1 = $_POST['sptele1'];
$type1 = $_POST['r1'];
//getting the new inputs for a new player
$naam2 = $_POST['spname2'];
$voornaam2 =$_POST['Firstname2'];
$mail2 = $_POST['spemail2'];
$geboortedatum2 = $_POST['datepicker2'];
$telefoon2 = $_POST['sptele2'];
$type2 = $_POST['r2'];
$myArray = array( "nul", "volwassene", "student", "kind met 8 lessen", "kind zonder 8 lessen");
//array that selects the right value for type
$bericht = "Beste " . $voornaam . " " . $name . ",\n" . "We hebben uw inschrijving goed ontvangen. \nHier hebt u nog eens de inschrijving. Als er iets niet correct zou zijn laat het ons weten (info@kltc.be). \n\r\n\r" . "NAAM: " . $voornaam ." ". $name . "\n E-MAIL: " . $from . "\n GEBOORTEDATUM: " . $geboortedatum . "\n TELEFOON: " . $telefoon . "\n TYPE: " . $myArray[$type] . "\n ADRES: " . $adres . "\n POSTCODE: " . $postcode . "\n HUISNR: " . $huisnr . "\n GEMEENTE: " . $gemeente . "\n PRIJS: " . $prijs . "\n\r\n\r Gelieve dit bedrag te storten op het rekeningnummer: IBAN: BE59 0017 9225 2226 van KLTC HERENT vzw of BIC: GEBABEBB \n\r met de vermelding : 'lidmaatschap 2019 '-' X aantal personen / gezin / lessen, ... enz.' \n Uw inschrijving is pas definitief als zowel het lidgeld betaald is en we het inschrijvingsformulier ontvangen hebben. \n !Deelname aan tennislessen kan alleen, nadat je het lesgeld betaald hebt. \n\r\n\r Wij hier bij KLTC HERENT heten u alvast welkom! \n\r\n\r !Dit is mogelijk gemaakt door Tobias Van Rickstal!";
$subject = "Inschrijving";
$subject2 = "Inschrijving bij KLTC";
$headers = "From: $from";
$headers2 = "From: $to";
mail($to,$subject,$bericht,$headers) or die("Error!");
echo "Bedankt," . $voornaam . $myArray[$type];
?>
Should I use an extra message(bericht)? or how should I do this the best way possible?
I also had some issues with the mailing, I would like to send a confirmation to the one who has filled the form. so one to the receiver and one to the sender, but I had some problems with it. Or I get only one in my inbox or I get an empty mail (no information of my inputs were published in the mail.