Skip to content

Instantly share code, notes, and snippets.

@luisciphere
Created November 3, 2018 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisciphere/476818812e12c66b2d4131dc80d16be2 to your computer and use it in GitHub Desktop.
Save luisciphere/476818812e12c66b2d4131dc80d16be2 to your computer and use it in GitHub Desktop.
<?php
/*
* Тут мы будем обрабатывать ошибки и выводить соответствующие сообщения
*/
if( isset( $_GET['msg'] ) ) {
// в случае успеха
if( $_GET['msg'] == 'success' )
echo '<span>Сообщение успешно отправлено</span>';
// в случае ошибки
if( $_GET['msg'] == 'error' )
echo '<span><strong>Ошибка:<strong> Проверьте правильность введённых вами данных.</span>';
// вы сами можете добавить различные другие сообщения об ошибках
}
/*
* Антиспам-трюк
* у нас есть два фейковых поля, при заполнении которых прерывается выполнение скрипта
* сделаем так, чтобы они были скрыты для пользователей при помощи CSS
*/
echo '<style>textarea[name="comment"],textarea[name="message"]{display:none}</style>';
?>
<div class="form-wrap">
<h2 class="facility-card__heading facility-card__heading--tc">Request a reservation</h2>
<form name="form" method="post" enctype="multipart/form-data" action="" class="form" id="request-form">
<label for="name" class="label">Your Name</label>
<input type="text" name="name" id="name" class="input-field" required>
<label for="email" class="label">Your Email</label>
<input type="email" name="email" id="email" class="input-field" required>
<label for="phone" class="label">Phone Number</label>
<input type="tel" name="phone" id="phone" class="input-field" required>
<label for="facility-requested" class="label">Facility Requested</label>
<select name="facility-requested" id="facility-requested" class="input-select" required>
<option disabled selected>Select one</option>
<?php while ( have_posts() ) : the_post(); ?>
<option value="<?php the_title(); ?>" id="requested<?php the_ID(); ?>"><?php the_title(); ?></option>
<?php endwhile; ?>
</select>
<label for="reservation-date" class="label">Reservation Date</label>
<input type="date" name="reservation-date" id="reservation-date" class="input-field" required>
<label for="type-of-event" class="label">Type of Event - <em>Optional</em></label>
<input type="text" name="type-of-event" id="type-of-event" class="input-field" placeholder="e.g. Wedding reception">
<label for="number-of-guests" class="label">Number of Guests - <em>Optional</em></label>
<input type="number" name="number-of-guests" id="number-of-guests" class="input-field" min="1">
<input type="checkbox" name="subscribe-newsletter" id="subscribe-newsletter" class="input-checkbox" checked value="1">
<label for="subscribe-newsletter" class="label">Sign me up for the newsletter!</label>
<textarea name="comment" id="comment"></textarea>
<textarea name="message" id="message"></textarea>
<button type="submit" class="button button__hero button__hero--wide">Get in touch</button>
</form>
<div id="success-form" style="display:none;">
Thank you for your request.
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment