This is one of the “Hello, World”s of programming exercises. Are you ready to learn a little PHP? You can set a cookie and read it on every following page. If you set a session cookie, then the name will disappear after they close their browser. If they return, they will have to enter it again. But if you set a long-lived cookie, then it will recognize them when they return, even years later.
Walter
On Oct 18, 2014, at 9:18 AM, Hoffkids email@hidden wrote:
Hi all,
I have a page where the visitor types their name and hits a button.
After they hit the button it brings them to the 2nd page and sends me an email of who visited.
Is it possible after they type their name in the box on 1st page, that their name appears on the 2nd page??
for example if they typed in Chris Smith in box and hit button, the next page would say 'Welcome Chris Smith"
And you can do this in JavaScript, too, if you don’t want to change all of your page filenames from .html to .php just to do this thing.
Walter
On Oct 18, 2014, at 10:31 AM, Walter Lee Davis email@hidden wrote:
This is one of the “Hello, World”s of programming exercises. Are you ready to learn a little PHP? You can set a cookie and read it on every following page. If you set a session cookie, then the name will disappear after they close their browser. If they return, they will have to enter it again. But if you set a long-lived cookie, then it will recognize them when they return, even years later.
Very easy. Let’s do it in JavaScript first, since that won’t require any changes to the rest of your site. First lesson of cookies — you can only read them on the NEXT page, not the current page. So if you set a variable in a cookie on one page, you can read it on the next, but not the current page.
Apply Protaculous 2 to the page, if you haven’t already. In the Additional JavaScript Libraries section, enter ‘cookiejar’ (without the quotes) in the name field, and ‘http://cdn.freewaypro.com/cookiejar/1.5.1/cookiejar.js’ (without the quotes) in the CDN URI field.
Draw an HTML box where you want the name form to appear, and insert a text field and a button in it. Name the text field ‘name’, using the Name/ID field of the Inspector, and confirm in the third tab that the Name attribute is properly set to ‘name’. Name the button ‘send’, using the same degree of care. Set the Value of the send button to whatever you like. (Optional: if you want the setting of the name to automatically navigate the user to the next page, then in the Page / Form Setup, set the Action to the actual filename of the second page, and the Method to GET.)
On the second page, draw an HTML box where you want the name to appear, and type out a placeholder name. Using the Inspector, change the name of this HTML box to nameDisplay. When styling the name in the placeholder, make sure that you use a Paragraph style, not an inline (Inspector-made) style. Select the name, and make sure that the style that is highlighted in the Styles palette has a pilcrow (¶) before its name.
On that same page, apply the Protaculous 2 Action, also include the link to the cookiejar script, and in the DOM Loaded Observer, type the following: cookie-read.js · GitHub
What this will do is redirect the user back to the index.html page if they haven’t entered their name (assuming of course that index.html is where that happens) so adjust that URL if it’s not correct.
Walter
On Oct 18, 2014, at 10:34 AM, Hoffkids email@hidden wrote:
Walt,
I just want them to see it on the next page, each time (not years later).
I am ready for a very little PHP. Is it easy to enter?
You may also find my old PHP Getting Started pages worth exploring. I
wrote them as a learning exercise for myself, expanded them into a
MacUser magazine feature, then put a version online here: http://www.thehelpful.com/php/
This was some years ago, but there’s nothing here that’s out of date.
The Cookies section of the document doesn’t show exactly what you want
to do, but it’s very close!
Thanks so much for this last month… I have finally gotten around to doing it and despite not being totally finished (as I am trying next to get it to work with my PHP form so I get email notification), it is working as you said and very cool!
This is interesting…
I have followed all your above steps and even what Dave has mentioned to some degree to use the PHP feedback form as well to get a notification email.
Actually all is working as I imagined and seems too good to be true.
The only thing is, I cannot get the validate action to work with all I the javascript I have added.
for this student/parent HW page , I really would like it to work as it was before where something always had to be typed in the box or an error message displayed. I know people could just type anything, and I even know they could bookmark the 2nd page and bypass, but for 99.5% of the time it is used honestly and effectively.
So, do you think I can still get the validate action to work with our new “hello feature?”. Here is the new test page below. Just type your name in the box to see it in action.
if you do NOT type anything, it brings you to page 2 showing nameDisplay and a weird fast moving bar (that does not look good) near the top of the URL.
I did that change. The result is if no name is typed in, it flashes the 2nd HW page and shows 404 error.
This happens if nothing is typed in box and button hit, or if just button pressed.
In a way, this is an improvement in that they have to type something in the box now, but it did not do as you thought where it redirected person back to login page.