Click to See Complete Forum and Search --> : Need help with cookies


Lotz
August 28th, 2003, 02:53 PM
Hello,

It is my first post to that forum and I hope that someone could help me.

I visited many websites with tutorial about cookies, but I couldn't find what I'm looking for. :confused:

I have a form with the following fields: firstname, lastname, donation amount and email. When you click on the submit button, the form is sent (CGI with method=POST), a thank you page (thankyou.html) is displayed and I receive the info by email.

I would like to personalize the thank you page, like this:

Dear "firstname" "lastname",

Thanks you very much for you donation of "amount".
...

I would like that the firstname, lastname and donation amount are displayed on the thank you page, with the values submitted in the form.

The thank you page is a static HTML page (thankyou.html), that is uploaded on the server.
This page won't be created by the cgi script. It is just redirected to it.
The thank you page is created by me.
Then, I have a complete control on the page... I can put what I want on that page (images, javascript, etc.).

I think the best should be to do it with cookies, as I don't have access to the script CGI.

The cookie should be deleted when the thank you page is closed.

I tried to have it works for few weeks now, but I couldn't. :mad:

It would be very kind if someone could help me.

Thanks a lot in advance.

ZoSoo7
August 28th, 2003, 03:23 PM
Try this

Before the page is submitted, use an event then do some javascript that can write the cookie, off the top of my head, I don't remember how to do it in js, but you should be able to find it easily.

<script language="javascript">
function writeCookie()
{
//write cookie, I think it's somthing like this
document.cookie = "Name= " + document.getElementById("name").value + ";(and whatever else you want to use, delimit it with a ;)";

document.frm1.submit();
}
</script>

<form id=frm1 method=post action="blah.cgi">
<input type=text id="name">
<input type=submit onClick="javascript:writeCookie();">

jalarie
September 5th, 2003, 11:48 AM
You may find the help you need on the "Samples of my work > Cookies" page at my site:

&nbsp;http://spruce.flint.umich.edu/~jalarie/