[Express] Brewery Website

Hey guys!

I’m a newb. I am building a website for a brewery.

And I need to build a homepage that ask for birthdate in order for someone to continue on to the website, otherwise they will be kicked off.

Can someone help me on this?


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you’re not really serious about this, you can do it with
JavaScript. If there are legal ramifications if someone sees your site
(gasp!) about beer (egads!) before their age of majority (horrors!)
then you can do more serious things like server-side validation to
keep the young’uns away.

Here’s one stab at the JavaScript way. It’s cheap and cheerful, and
won’t annoy people except once. Anyone with half a brain can just
disable JS and see your site anyway – but you actually want this,
because you don’t want to keep Google out of your business.

In your Master Page, go to the Page / HTML Markup dialog, and move to
the Before /head section using the picker in the bottom-left corner.
Enter the following:

<script type="text/javascript">
if(!(document.cookie && document.cookie.match(/old_enough/))){
	window.location.href = 'age_form.html';
}
</script>

So what this does is look up the document cookie with JavaScript, see
if you’ve already set a cookie for this user (well, browser anyway).
If not, then you redirect to a new page called age_form.html.

Next step is to create this age_form page. But don’t just make a page
based on the same master you just modified – you’ll end up with the
tricky script above on that page as well. Make a new Master page, and
base your new form page on that. If you choose to make the filename
something other than age_form.html, be sure to modify the script above
to match. Note that you can have completely different page Title and
page Filename, and only the latter will matter in this case.

On your form page, you only need to have the form field and any
instructions required. It’s very important that you don’t include any
navigation links on this page at all, because you don’t want it to end
up in a search result anywhere. Doing so would break the simple system
for returning the visitor to their original page after they confirm
their age.

I’m assuming that you used the third tab from the left in the
Inspector to name your birth year field ‘birthyear’ (without the
quotes). You’ll need to add instructions for your users that they must
enter the full YYYY year.

In the Page Markup dialog, you’ll add a bit more code this time, and
to a different part of the page – Before /body:

<script type="text/javascript">
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

var checkform = document.forms[0];
var birthdate = checkform.birthyear;
checkform.onsubmit = function(evt){
	evt.preventDefault();
	var d = new Date();
	var y = parseInt(birthyear.value,10);
	if(y > 1900) //they entered something date-like
		d.setFullYear(y);
	var d2 = new Date();
	d2.setFullYear(d2.getFullYear() - 21);
	if(d <= d2){ //they are 21 or older
		createCookie('old_enough','true',365); //one year
		var next = document.referrer || 'index.html';
		document.location.href = next;
	}else{
		alert('Sorry, this Web site is only for persons old enough to  
drink!');
	}
	return false;
};
</script>

As long as you have named your form field correctly, this should just
work out of the box. If you have questions or can’t seem to get it
working, please upload it somewhere that we can see it (on your own
server, perhaps) and post a link here where we can try it out.

Walter

On Jun 7, 2011, at 8:47 PM, Brent wrote:

Hey guys!

I’m a newb. I am building a website for a brewery.

And I need to build a homepage that ask for birthdate in order for
someone to continue on to the website, otherwise they will be kicked
off.

Can someone help me on this?


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hello, it’s been a while since I have done any web work because of medical problems and because of those problems I can not concentrate like I could before. Therefore I could use some help please.

I’m basically trying to do the same thing here, but for a dispensary in Colorado. I’m trying to make it so when someone goes to the website for the first time, they have to enter their birth date in order to enter the website.

I have followed these instructions the best I could, but I am screwing something up in the form. A success or error page is not needed in this case I do believe, just for if the age is correct that the person can then enter the website.

The links are http://thewalkingraven.com and The Walking Raven Medical & Recreational Marijuana Center Denver Colorado

Shouldn’t the age_form page be a PHP page instead of html?

Thanks in advance for any and all help!

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

A couple of things

1 - you appear to have applied the php feedback form action to this page age_form.html - take it off.

2 - you haven’t named your birth year field correctly - and what is more it doesn’t look like a field you should put your birth year in.

Select the field and under the 3rd tab in the inspector make sure it says name: ‘birthyear’ - no quotes. And make it a field not a text area.

Change them and try again.

David


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Shouldn’t the age_form page be a PHP page instead of html?

No - no php on this page.

D


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hello Dave,

Thanks for the reply as I can certainly use the help. I am still a little lost on this, but feel that I am getting closer. I think I am having problems in setting up the form correctly and part of that is I might need to upload something separately to the CGI folder.

I did the first suggestion and took off the PHP Feedback Form action.

Still having questions/problems trying to figure out the second part.

Same links as before:

http://thewalkingraven.com/age_form.html

Thanks for the help!!!

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Select the birthyear field and make sure that both the name and the ID are birthyear.

D


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

B I N G O!!!

Thanks a lot Dave! That’s pretty trick.

Appreciate the help.

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’ve ran into a problem here now. I made a change to the page and it stopped working. I think the problem is that the year input field keeps renaming itself now!

I keep changing the name/id and the 3rd tab to the left name to birthyear and it keeps reverting to birthyear1 and sometimes now birthyear2!

I can not find where to remove the problem. Could you please explain how to fix this? It was working fine and I am not quite sure what I did wrong to make this happen.

Thanks a million!

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You can see the error in the URL!

http://thewalkingraven.com/age_form.html?month=&day=&birthyear=&month=06&day=10&birthyear2=1955&submit=Submit

Will I have to start entirely over? Or is there a way to fix this automatic renaming “problem” I am having?

TIA,

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You appear to have multiple birthyear input fields on the page

Look in the page/site side panel with the cog at the bottom set to ‘Show Items’

Look down the list for birthyear, birthyear1 and birthyear2 - delete until only birthyear is left.

D


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The odd thing about the problem, once you told me how to expose all the items is that there wasn’t a birthyear, birthyear1 and birthyear2!

There was just birthyear1 and it was very tough to get the renaming to happen, but I finally got it. But then another problem happen and when I would submit a correct age, I would get the error that I need to be 21.

So I went back to my SuperDuper backup copy from early this morning while I was sleeping, made a copy of that and brought it over to my laptop and started to use that as my newest version and now all is good!

I had made a change in the page early this afternoon and did not think about something I needed to do first, which is what started all of this.

Thanks again for the help,

Robert


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options