<? if($_POST): $error = 'Такой емэйл уже зарегистрирован' . filter_input(INPUT_POST, 'reg_email'); ?>
<div id="error_message" style="width:200px; color:red; position:fixed; left:50%; margin-left:-100px; text-align:center;">
<?= $error ?>
</div>
<? endif ?>
<form>
<!-- код формы -->
</form>
<?
session_start();
if($_POST['is18years'] == 'yes' || $_POST['is18years'] == 'no') $_SESSION['is18years'] = $_POST['is18years'];
if(isset($_SESSION['is18years'])) {
if($_SESSION['is18years'] == 'no') {
header("Location: /access_denied.html");
exit;
}
}
?><?
if(!isset($_SESSION['is18years'])):
?>
<div class="body_overhead">
<div class="overhead_window">
<div class="oh_wnd_header">
<p>Доступ к сайту могут осуществлять только лица, достигшие возраста 18 лет</p>
<p style="font-weight: bold;">Вам уже есть 18 лет?</p>
<p>
<span style="color: green" class="is18years yes18">ДА, мне уже есть 18 лет</span> | <span style="color: red" class="is18years no18">НЕТ, мне еще нет 18 лет</span>
</p>
</div>
</div>
</div>
<style>
.body_overhead {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.95);
z-index: 999999999;
}
.overhead_window {
top: 10%;
left: 30%;
width: 40%;
background: #fff;
position: relative;
}
.oh_wnd_header {
padding: 20px;
color: #333;
text-align: center;
}
.is18years {
cursor: pointer;
}
</style>
<?
endif;
?>
<script>
// проверка на 18 лет
$('.is18years').click(function(){
if($(this).hasClass('yes18') || $(this).hasClass('no18')) {
var is18years = $(this).hasClass('yes18') ? 'yes' : 'no'
$.ajax({
type: "POST",
context: document.head,
data: { is18years: is18years },
success: function(){
if(is18years === 'yes') {
$('.body_overhead').hide()
} else {
document.location.href = '/access_denied.html'
}
}
})
}
})
</script>
$text = preg_replace('/\s+/', ' ', $text); // убираем склеенные пробелы
$array = explode(' ', $text); // делим как обычно по пробелам
$('select').change(function() {
if ( navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 ) {
var selIndex = $(this).find('option:selected').index()+1;
$(this)
.find('option')
.removeAttr('selected')
.end()
.find('option:nth-child('+selIndex+')')
.attr('selected', 'selected')
.end()
.find('option:not(:nth-child('+selIndex+'))')
.prop('selected', false)
.end()
.find('option:nth-child('+selIndex+')')
.prop('selected', true)
} else {
var selIndex = $(this).find('option:selected').index()+1;
$(this).find('option').removeAttr('selected').end().find('option:nth-child('+selIndex+')').attr('selected', 'selected');
$(this).val($(this).find('option[selected="selected"]').val());
}
// $(this).val()
$.ajax({
url: '',
data: {
a: $(this).val()
},
// ...
})
})