Hello to all,i just want a little help i find several script's but no one works for me i don't know why..So i ask u for help.
I Need a Script that will ask you how old are you (Day Month Year).You enter the Day Month Year and if u are under 14 years (or 18) u cannot enter,and the website to Remember you're IP address and that u are Under or Over 14 years.And if you are Under u cannot Enter the site,but if u are Over 14 years u enter.
I Need when u press Submit (whit an image button) if you under to go to a page that explain that u are under 14 years and u cannot enter.But if you are over 14 and pres submit to enter the site whit no problems.And to remember that you have those years.
Help whit Age check script
Weedpacket has contributed an age/birthday script sometime in the past (though I believe it was brought up recently in another thread by someone using it), so using his function would let you easily determine the age.
After that, just start a [man]session[/man] and store the calculated age in there.
bradgrafelman dude i don't think i understand you.Becoas i don't know that "Weedpacket" you are talking about or how to put it ... Becoas i just whant 1 Script that will Allow User's who are older than 14 Year's (when pres Submit) to enter or to not enter if they are under 14 year's old.
The Page where the script will be put on will have only Background Image , Image Submit Button , and a few "banner exchange" pictures (. gif or . jpg).
That's all...ohh yes and when you Enter 1 Time (only 1 time) you're age you can't change it,and when u enter the page (main where will be this script) and you have already enter you're age (Over 14) it will redirect you to the (index) official page.
Example :
I Enter my birthday (under 14) it give me a Page that tell me that i can't enter the site. (restricted.html)
I Try to enter the site again and enter another age (that I'm 15) and to enter into the site,but the page (main.html) redirect me to the restricted page and i can't enter this site anymore.
But if I'm over 14 years and enter it (for the first time in the main page) it will take me to the official page (index.html) and every time i go to the Main page it automatically re-direct me to the official page (index.html)
I Try
Weedpacket is one of the people frequently answering questions here. This is the thread bradgrafelman was referring to.
johanafm;10939013 wrote:Weedpacket is one of the people frequently answering questions here. This is the thread bradgrafelman was referring to.
ok...but i need a script...in that topic it's a calculator...not a script whit submit button and Autodirect...
If you start witing your PHP/HTML script
we will help you finish it.
Just give us something to start with.
Hmmm.. ok i find 1 script but i don't know what to change in it to make it when u pres submit to redirect u into the site If u are over 14 and if u are under to make u go to the restrict page.
And then automatically when u go to my site to redirect you to the Site or to the Restrict page...
Here is the code in the Page to put in
// Assumptions
// 3 form select fields with id= "month", "day", and "year"
//
//
function updateDays()
{
var i;
var monthDays = [31,29,31,30,31,30,31,31,30,31,30,31];
var monthSelect = document.getElementById("month");
var daySelect = document.getElementById("day");
var mIndex = monthSelect.selectedIndex-1;
var days = monthDays[mIndex];
daySelect.length = days+1;
for (i=1; i <= days; i++)
{
daySelect.options[i].text = i;
daySelect.options[i].value = i;
}
}
function getFullYear(d)
{
var y = d.getYear();
if (y < 1000) y += 1900;
return y;
}
function setYears()
{
var i, j;
var yearsBack = 60;
var today = new Date();
var thisYear = getFullYear(today);
var firstYear = thisYear - yearsBack; //go back 60 years - should be enough
var yearSelect = document.getElementById("year");
yearSelect.length = yearsBack+2;
j = thisYear;
for ( i=1; i <= yearsBack+2; i++ )
{
yearSelect.options[i].text = j;
yearSelect.options[i].value = j;
j--;
}
}
function isOldEnough(minYears)
{
var today = new Date();
var monthSelect = document.getElementById("month");
var daySelect = document.getElementById("day");
var yearSelect = document.getElementById("year");
if (yearSelect.selectedIndex != 0 || monthSelect.selectedIndex != 0 && daySelect.selectedIndex != 0)
{
var birthYear = yearSelect.options[yearSelect.selectedIndex].value;
var birthMonth = monthSelect.selectedIndex-1;
var birthDay = daySelect.selectedIndex
var years = getFullYear(today) - birthYear;
var months = today.getMonth() - birthMonth;
var days = today.getDate() - birthDay;
if (days < 0) months--;
if (months < 0) years--;
if (years >= minYears)
return true;
}
return false;
}
function dropCookiePass(name)
{
var expiresDate = new Date();
expiresDate.setFullYear( getFullYear(expiresDate) + 1 ); // expires in a year
document.cookie = name + "=true;expires=" + expiresDate.toString();
}
function dropCookieRestrict(name, expiresDate)
{
document.cookie = name + "=false;expires=" + expiresDate.toString();
}
function cookieStore(name, expiresDate)
{
document.cookie = name + "=false;expires=" + expiresDate.toString();
}
function cookieExists(name)
{
var allcookies = document.cookie;
var pos = allcookies.indexOf(name);
if (pos == -1)
return false;
else
return true;
}
function isRestricted(name)
{
var allcookies = document.cookie;
var key=name+"=";
var start = allcookies.indexOf(key);
var end;
if (start != -1)
{
start += key.length;
end = allcookies.indexOf(';', start);
if (end == -1) end = allcookies.length;
var cookieval = allcookies.substring(start, end);
if (cookieval=="false")
return true;
}
return false;
}
function getExpirationDate(age)
{
var today = new Date();
var monthSelect = document.getElementById("month");
var daySelect = document.getElementById("day");
var yearSelect = document.getElementById("year");
var birthYear = yearSelect.options[yearSelect.selectedIndex].value;
var birthMonth = monthSelect.selectedIndex-1;
var birthDay = daySelect.selectedIndex
var years = getFullYear(today) - birthYear;
var months = today.getMonth() - birthMonth;
var days = today.getDate() - birthDay;
if (days < 0) months--;
if (months < 0) years--;
var ofAgeDate = new Date()
ofAgeDate.setDate(birthDay);
ofAgeDate.setMonth(birthMonth);
ofAgeDate.setFullYear(parseInt(birthYear) + (age - years));
ofAgeDate.setHours(0);
ofAgeDate.setMinutes(0);
ofAgeDate.setSeconds(0);
return ofAgeDate;
}
function isOfAge(age,name,denyPage)
{
if (!isOldEnough(age))
{
dropCookieRestrict(name, getExpirationDate(age));
location.href = denyPage;
return false;
}
else
{
dropCookiePass(name);
return true;
}
}
function allFieldsSelected()
{
var monthSelect = document.getElementById("month");
var daySelect = document.getElementById("day");
var yearSelect = document.getElementById("year");
if (yearSelect.selectedIndex != 0 || monthSelect.selectedIndex != 0 && daySelect.selectedIndex != 0)
return true;
else
return false;
}
// site specific age gate cookie check
var tag = "MK_DCU";
function checkAge()
{
if ( allFieldsSelected() )
{
return isOfAge(13, tag,"restricted.html");
}
alert ("All birth date fields must be selected");
return false;
}
var url = document.URL.toString();
if (url.indexOf("index.html") != -1)
{
if (cookieExists(tag))
{
if (isRestricted(tag))
{
location.href = 'restricted.html';
}
else
{
location.href = 'main.html';
}
}
}
else if (url.indexOf("main.html") != -1)
{
if (cookieExists(tag))
{
if (isRestricted(tag))
{
location.href = 'restricted.html';
}
}
else
{
location.href = 'index.html'; // go to age gate page
}
}
else
{
if (cookieExists(tag))
{
if (isRestricted(tag))
{
location.href = 'restricted.html';
}
else
{
location.href = 'main.html';
}
}
else
{
location.href = 'index.html'; // go to age gate page
}
}
And here is the Code in the agegate.js
<script type="text/javascript" language="javascript" src="agegate.js"></script>
</head>
<body id="home_ag" onload="javascript:setYears();">
<div id="pgcenter_ag">
<div id="age_gate">
<form action="main.html" onsubmit="return checkAge();">
<select id="month" name="month" onchange="javascript:updateDays();" >
<option value="">[ Month ]</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select id="day" name="day">
<option>[ Day ]</option>
</select>
<select id="year" name="year">
<option>[ Year ]</option>
</select>
<input type="image" src="img/submit.jpg" name="" value="Submit" id="">
</form>
</div>
So now help me whit this thing..