Skip to content

Commit

Permalink
Merge pull request #17 from tekylo/develop
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
tekylo authored Sep 17, 2020
2 parents 68328b4 + 5553f52 commit e90b6bb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 37 deletions.
7 changes: 7 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1517,3 +1517,10 @@ footer:before {
color: black;
opacity: 1; /* Firefox */
}

.error_message {
color: #F33;
font-weight: 600;
margin-bottom: 4px;
font-size: 14px;
}
Binary file modified favicon.ico
Binary file not shown.
39 changes: 28 additions & 11 deletions form.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
<?php
// Configure your number Prefix and Recipient here
$subject = '[Contact via website]'; // email subject
$emailTo = 'your-email@gmail.com'; // change to your email
$subject = 'RSVP'; // email subject
$emailTo = 'samarybaltasar@gmail.com'; // change to your email
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
$day = array();
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = stripslashes(trim($_POST['name']));
$friendName = stripslashes(trim($_POST['friendName']));
$number = stripslashes(trim($_POST['number']));
foreach (stripslashes(trim($_POST['day'])) as $item) {
$day[] = $item;
}
$food = stripslashes(trim($_POST['food']));

if (empty($food)) {
$food = 'Ninguna';
}
$day = $_POST['day'];

if (empty($name)) {
$errors['name'] = 'Name is required.';
}
if (empty($friendName)) {
$errors['friendName'] = 'Friend Name is required.';
$errors['name'] = 'Nombre es requerido.';
}

if (empty($number)) {
$errors['number'] = 'Teléfono o correo es requerido.';
}

if (empty($day[0]) && empty($day[1])) {
$errors['day'] = 'Día es requerido.';
}
// if there are any errors in our errors array, return a success boolean or false
if (!empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$body = '
<strong>Name: </strong>'.$name.'<br />
<strong>Friends Name: </strong>'.$friendName.'<br />
<strong>Contact info: </strong>'.$number.'<br />
<strong>Nombre: </strong>'.$name.'<br />
<strong>Acompañante: </strong>'.$friendName.'<br />
<strong>Días: </strong>'.$day[0].' '.$day[1].'<br />
<strong>Alergia: </strong>'.$food.'<br />
<strong>Información de Contacto: </strong>'.$number.'<br />
';
$headers = "MIME-Version: 1.1" . PHP_EOL;
$headers .= "Content-type: text/html; charset=utf-8" . PHP_EOL;
Expand All @@ -37,8 +54,8 @@
mail($emailTo, "=?utf-8?B?" . base64_encode($subject) . "?=", $body, $headers);
$data['success'] = true;
// Change the Success message here
$data['message'] = 'Thank you, ' . $name . '! Waiting you on our wedding!';
$data['message'] = 'Gracias, ' . $name . ' ¡Te esperamos en nuestra boda!';
}
// return all our data to an AJAX call
echo json_encode($data);
}
}
33 changes: 11 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,38 +272,27 @@ <h6 class="text-uppercase font-weight-bold mb-0">¿ASISTIRÁS?</h6>
<div class="col-md-8 mb-3 m-md-0">
<div class="form-group">
<!-- <label class="control-label" for="inputName">Nombre</label>-->
<input type="text" class="form-control" id="inputName" placeholder="Nombre" required>
<input type="text" class="form-control" id="inputName" placeholder="Nombre">
</div>
<div class="form-group">
<!-- <label class="control-label" for="inputFriendName">Acompañante</label>-->
<input type="text" class="form-control" id="inputFriendName" placeholder="Acompañante" required>
<input type="text" class="form-control" id="inputFriendName" placeholder="Acompañante">
</div>
<div class="form-group">
<!-- <label class="control-label" for="inputNumber">Teléfono o correo</label>-->
<input type="text" class="form-control" id="inputNumber" placeholder="Teléfono o correo">
<div class="form-group">
<select title="¿Que día/días asistirás?" class="selectpicker" multiple>
<option>Viernes</option>
<option>Sábado</option>
<!-- <option>4</option>-->
</select>
</div>
<div class="form-group">
</div>
<div class="form-group">
<select title="¿Que día/días asistirás?" name="inputDay" id="inputDay" class="selectpicker" multiple>
<option value="Viernes">Viernes</option>
<option value="Sábado">Sábado</option>
</select>
</div>
<div class="form-group">
<!-- <label class="control-label" for="inputName">Por favor, indica si tienes alguna preferencia de dieta o si tienes alguna intolerancia o alergia a tener en cuenta. Gracias</label>-->
<textarea rows="5" type="text" class="form-control" placeholder="Por favor, indica si tienes alguna preferencia de dieta o si tienes alguna intolerancia o alergia a tener en cuenta. Gracias"></textarea>
</div>
<textarea rows="5" type="text" name="inputFood" id="inputFood" class="form-control" placeholder="Por favor, indica si tienes alguna preferencia de dieta o si tienes alguna intolerancia o alergia a tener en cuenta. Gracias"></textarea>
</div>
</div>
<!-- <div class="form-group">-->
<!-- <p>Elige el día</p>-->
<!-- <select class="selectpicker" multiple>-->
<!-- <option>2</option>-->
<!-- <option>3</option>-->
<!-- <option>4</option>-->
<!-- </select>-->
<!-- </div>-->


<div class="col-md-4 align-self-end">
<button type="submit" class="btn btn-outline-dark rounded-0 px-3 py-1 font-weight-bold">Enviar</button>
</div>
Expand Down
13 changes: 9 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ Table of Contents:
var formData = {
'name': $form.find('input#inputName').val(),
'friendName': $form.find('input#inputFriendName').val(),
'number': $form.find('input#inputNumber').val()
'number': $form.find('input#inputNumber').val(),
'day': $form.find('select#inputDay').val(),
'food': $form.find('textarea#inputFood').val()
};

$.ajax({
Expand All @@ -265,9 +267,12 @@ Table of Contents:
} else {
if (data.errors.name) {
$('#inputName').addClass('error').after('<span class="error-msg">'+data.errors.name+'</span>');
} else if (data.errors.friendName) {
$('#inputFriendName').addClass('error').after('<span class="error-msg">'+data.errors.friendName+'</span>');
}else if (data.errors.number) {
$('#inputNumber').addClass('error').after('<span class="error-msg">'+data.errors.number+'</span>');
} else if (data.errors.day) {
$('#inputDay').addClass('error').after('<span class="error-msg">'+data.errors.day+'</span>');
}

}
});
e.preventDefault();
Expand Down Expand Up @@ -332,4 +337,4 @@ Table of Contents:
IEdetect();
});

}());
}());

0 comments on commit e90b6bb

Please sign in to comment.